1--TEST--
2Test parse_url() function: Parse a load of URLs without specifying the component
3--FILE--
4<?php
5/* Prototype  : proto mixed parse_url(string url, [int url_component])
6 * Description: Parse a and return its components
7 * Source code: ext/standard/url.c
8 * Alias to functions:
9 */
10
11/*
12 * Parse a load of URLs without specifying the component
13 */
14include_once(dirname(__FILE__) . '/urls.inc');
15
16foreach ($urls as $url) {
17	echo "\n--> $url: ";
18	var_dump(parse_url($url));
19}
20
21echo "Done";
22?>
23--EXPECTF--
24
25--> 64.246.30.37: array(1) {
26  ["path"]=>
27  string(12) "64.246.30.37"
28}
29
30--> http://64.246.30.37: array(2) {
31  ["scheme"]=>
32  string(4) "http"
33  ["host"]=>
34  string(12) "64.246.30.37"
35}
36
37--> http://64.246.30.37/: array(3) {
38  ["scheme"]=>
39  string(4) "http"
40  ["host"]=>
41  string(12) "64.246.30.37"
42  ["path"]=>
43  string(1) "/"
44}
45
46--> 64.246.30.37/: array(1) {
47  ["path"]=>
48  string(13) "64.246.30.37/"
49}
50
51--> 64.246.30.37:80/: array(3) {
52  ["host"]=>
53  string(12) "64.246.30.37"
54  ["port"]=>
55  int(80)
56  ["path"]=>
57  string(1) "/"
58}
59
60--> php.net: array(1) {
61  ["path"]=>
62  string(7) "php.net"
63}
64
65--> php.net/: array(1) {
66  ["path"]=>
67  string(8) "php.net/"
68}
69
70--> http://php.net: array(2) {
71  ["scheme"]=>
72  string(4) "http"
73  ["host"]=>
74  string(7) "php.net"
75}
76
77--> http://php.net/: array(3) {
78  ["scheme"]=>
79  string(4) "http"
80  ["host"]=>
81  string(7) "php.net"
82  ["path"]=>
83  string(1) "/"
84}
85
86--> www.php.net: array(1) {
87  ["path"]=>
88  string(11) "www.php.net"
89}
90
91--> www.php.net/: array(1) {
92  ["path"]=>
93  string(12) "www.php.net/"
94}
95
96--> http://www.php.net: array(2) {
97  ["scheme"]=>
98  string(4) "http"
99  ["host"]=>
100  string(11) "www.php.net"
101}
102
103--> http://www.php.net/: array(3) {
104  ["scheme"]=>
105  string(4) "http"
106  ["host"]=>
107  string(11) "www.php.net"
108  ["path"]=>
109  string(1) "/"
110}
111
112--> www.php.net:80: array(2) {
113  ["host"]=>
114  string(11) "www.php.net"
115  ["port"]=>
116  int(80)
117}
118
119--> http://www.php.net:80: array(3) {
120  ["scheme"]=>
121  string(4) "http"
122  ["host"]=>
123  string(11) "www.php.net"
124  ["port"]=>
125  int(80)
126}
127
128--> http://www.php.net:80/: array(4) {
129  ["scheme"]=>
130  string(4) "http"
131  ["host"]=>
132  string(11) "www.php.net"
133  ["port"]=>
134  int(80)
135  ["path"]=>
136  string(1) "/"
137}
138
139--> http://www.php.net/index.php: array(3) {
140  ["scheme"]=>
141  string(4) "http"
142  ["host"]=>
143  string(11) "www.php.net"
144  ["path"]=>
145  string(10) "/index.php"
146}
147
148--> www.php.net/?: array(1) {
149  ["path"]=>
150  string(12) "www.php.net/"
151}
152
153--> www.php.net:80/?: array(3) {
154  ["host"]=>
155  string(11) "www.php.net"
156  ["port"]=>
157  int(80)
158  ["path"]=>
159  string(1) "/"
160}
161
162--> http://www.php.net/?: array(3) {
163  ["scheme"]=>
164  string(4) "http"
165  ["host"]=>
166  string(11) "www.php.net"
167  ["path"]=>
168  string(1) "/"
169}
170
171--> http://www.php.net:80/?: array(4) {
172  ["scheme"]=>
173  string(4) "http"
174  ["host"]=>
175  string(11) "www.php.net"
176  ["port"]=>
177  int(80)
178  ["path"]=>
179  string(1) "/"
180}
181
182--> http://www.php.net:80/index.php: array(4) {
183  ["scheme"]=>
184  string(4) "http"
185  ["host"]=>
186  string(11) "www.php.net"
187  ["port"]=>
188  int(80)
189  ["path"]=>
190  string(10) "/index.php"
191}
192
193--> http://www.php.net:80/foo/bar/index.php: array(4) {
194  ["scheme"]=>
195  string(4) "http"
196  ["host"]=>
197  string(11) "www.php.net"
198  ["port"]=>
199  int(80)
200  ["path"]=>
201  string(18) "/foo/bar/index.php"
202}
203
204--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
205  ["scheme"]=>
206  string(4) "http"
207  ["host"]=>
208  string(11) "www.php.net"
209  ["port"]=>
210  int(80)
211  ["path"]=>
212  string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
213}
214
215--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php?lots=1&of=2&parameters=3&too=4&here=5: array(5) {
216  ["scheme"]=>
217  string(4) "http"
218  ["host"]=>
219  string(11) "www.php.net"
220  ["port"]=>
221  int(80)
222  ["path"]=>
223  string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
224  ["query"]=>
225  string(37) "lots=1&of=2&parameters=3&too=4&here=5"
226}
227
228--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/: array(4) {
229  ["scheme"]=>
230  string(4) "http"
231  ["host"]=>
232  string(11) "www.php.net"
233  ["port"]=>
234  int(80)
235  ["path"]=>
236  string(45) "/this/is/a/very/deep/directory/structure/and/"
237}
238
239--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php: array(4) {
240  ["scheme"]=>
241  string(4) "http"
242  ["host"]=>
243  string(11) "www.php.net"
244  ["port"]=>
245  int(80)
246  ["path"]=>
247  string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
248}
249
250--> http://www.php.net:80/this/../a/../deep/directory: array(4) {
251  ["scheme"]=>
252  string(4) "http"
253  ["host"]=>
254  string(11) "www.php.net"
255  ["port"]=>
256  int(80)
257  ["path"]=>
258  string(28) "/this/../a/../deep/directory"
259}
260
261--> http://www.php.net:80/this/../a/../deep/directory/: array(4) {
262  ["scheme"]=>
263  string(4) "http"
264  ["host"]=>
265  string(11) "www.php.net"
266  ["port"]=>
267  int(80)
268  ["path"]=>
269  string(29) "/this/../a/../deep/directory/"
270}
271
272--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php: array(4) {
273  ["scheme"]=>
274  string(4) "http"
275  ["host"]=>
276  string(11) "www.php.net"
277  ["port"]=>
278  int(80)
279  ["path"]=>
280  string(42) "/this/is/a/very/deep/directory/../file.php"
281}
282
283--> http://www.php.net:80/index.php: array(4) {
284  ["scheme"]=>
285  string(4) "http"
286  ["host"]=>
287  string(11) "www.php.net"
288  ["port"]=>
289  int(80)
290  ["path"]=>
291  string(10) "/index.php"
292}
293
294--> http://www.php.net:80/index.php?: array(4) {
295  ["scheme"]=>
296  string(4) "http"
297  ["host"]=>
298  string(11) "www.php.net"
299  ["port"]=>
300  int(80)
301  ["path"]=>
302  string(10) "/index.php"
303}
304
305--> http://www.php.net:80/#foo: array(5) {
306  ["scheme"]=>
307  string(4) "http"
308  ["host"]=>
309  string(11) "www.php.net"
310  ["port"]=>
311  int(80)
312  ["path"]=>
313  string(1) "/"
314  ["fragment"]=>
315  string(3) "foo"
316}
317
318--> http://www.php.net:80/?#: array(4) {
319  ["scheme"]=>
320  string(4) "http"
321  ["host"]=>
322  string(11) "www.php.net"
323  ["port"]=>
324  int(80)
325  ["path"]=>
326  string(1) "/"
327}
328
329--> http://www.php.net:80/?test=1: array(5) {
330  ["scheme"]=>
331  string(4) "http"
332  ["host"]=>
333  string(11) "www.php.net"
334  ["port"]=>
335  int(80)
336  ["path"]=>
337  string(1) "/"
338  ["query"]=>
339  string(6) "test=1"
340}
341
342--> http://www.php.net/?test=1&: array(4) {
343  ["scheme"]=>
344  string(4) "http"
345  ["host"]=>
346  string(11) "www.php.net"
347  ["path"]=>
348  string(1) "/"
349  ["query"]=>
350  string(7) "test=1&"
351}
352
353--> http://www.php.net:80/?&: array(5) {
354  ["scheme"]=>
355  string(4) "http"
356  ["host"]=>
357  string(11) "www.php.net"
358  ["port"]=>
359  int(80)
360  ["path"]=>
361  string(1) "/"
362  ["query"]=>
363  string(1) "&"
364}
365
366--> http://www.php.net:80/index.php?test=1&: array(5) {
367  ["scheme"]=>
368  string(4) "http"
369  ["host"]=>
370  string(11) "www.php.net"
371  ["port"]=>
372  int(80)
373  ["path"]=>
374  string(10) "/index.php"
375  ["query"]=>
376  string(7) "test=1&"
377}
378
379--> http://www.php.net/index.php?&: array(4) {
380  ["scheme"]=>
381  string(4) "http"
382  ["host"]=>
383  string(11) "www.php.net"
384  ["path"]=>
385  string(10) "/index.php"
386  ["query"]=>
387  string(1) "&"
388}
389
390--> http://www.php.net:80/index.php?foo&: array(5) {
391  ["scheme"]=>
392  string(4) "http"
393  ["host"]=>
394  string(11) "www.php.net"
395  ["port"]=>
396  int(80)
397  ["path"]=>
398  string(10) "/index.php"
399  ["query"]=>
400  string(4) "foo&"
401}
402
403--> http://www.php.net/index.php?&foo: array(4) {
404  ["scheme"]=>
405  string(4) "http"
406  ["host"]=>
407  string(11) "www.php.net"
408  ["path"]=>
409  string(10) "/index.php"
410  ["query"]=>
411  string(4) "&foo"
412}
413
414--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI: array(5) {
415  ["scheme"]=>
416  string(4) "http"
417  ["host"]=>
418  string(11) "www.php.net"
419  ["port"]=>
420  int(80)
421  ["path"]=>
422  string(10) "/index.php"
423  ["query"]=>
424  string(31) "test=1&test2=char&test3=mixesCI"
425}
426
427--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(5) {
428  ["host"]=>
429  string(11) "www.php.net"
430  ["port"]=>
431  int(80)
432  ["path"]=>
433  string(10) "/index.php"
434  ["query"]=>
435  string(31) "test=1&test2=char&test3=mixesCI"
436  ["fragment"]=>
437  string(16) "some_page_ref123"
438}
439
440--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
441  ["scheme"]=>
442  string(4) "http"
443  ["host"]=>
444  string(11) "www.php.net"
445  ["port"]=>
446  int(80)
447  ["user"]=>
448  string(6) "secret"
449  ["path"]=>
450  string(10) "/index.php"
451  ["query"]=>
452  string(31) "test=1&test2=char&test3=mixesCI"
453  ["fragment"]=>
454  string(16) "some_page_ref123"
455}
456
457--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(6) {
458  ["scheme"]=>
459  string(4) "http"
460  ["host"]=>
461  string(11) "www.php.net"
462  ["user"]=>
463  string(6) "secret"
464  ["path"]=>
465  string(10) "/index.php"
466  ["query"]=>
467  string(31) "test=1&test2=char&test3=mixesCI"
468  ["fragment"]=>
469  string(16) "some_page_ref123"
470}
471
472--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
473  ["scheme"]=>
474  string(4) "http"
475  ["host"]=>
476  string(11) "www.php.net"
477  ["port"]=>
478  int(80)
479  ["pass"]=>
480  string(7) "hideout"
481  ["path"]=>
482  string(10) "/index.php"
483  ["query"]=>
484  string(31) "test=1&test2=char&test3=mixesCI"
485  ["fragment"]=>
486  string(16) "some_page_ref123"
487}
488
489--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
490  ["scheme"]=>
491  string(4) "http"
492  ["host"]=>
493  string(11) "www.php.net"
494  ["user"]=>
495  string(6) "secret"
496  ["pass"]=>
497  string(7) "hideout"
498  ["path"]=>
499  string(10) "/index.php"
500  ["query"]=>
501  string(31) "test=1&test2=char&test3=mixesCI"
502  ["fragment"]=>
503  string(16) "some_page_ref123"
504}
505
506--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
507  ["scheme"]=>
508  string(4) "http"
509  ["host"]=>
510  string(11) "www.php.net"
511  ["port"]=>
512  int(80)
513  ["user"]=>
514  string(14) "secret@hideout"
515  ["path"]=>
516  string(10) "/index.php"
517  ["query"]=>
518  string(31) "test=1&test2=char&test3=mixesCI"
519  ["fragment"]=>
520  string(16) "some_page_ref123"
521}
522
523--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
524  ["scheme"]=>
525  string(4) "http"
526  ["host"]=>
527  string(11) "www.php.net"
528  ["port"]=>
529  int(80)
530  ["user"]=>
531  string(6) "secret"
532  ["pass"]=>
533  string(7) "hid:out"
534  ["path"]=>
535  string(10) "/index.php"
536  ["query"]=>
537  string(31) "test=1&test2=char&test3=mixesCI"
538  ["fragment"]=>
539  string(16) "some_page_ref123"
540}
541
542--> nntp://news.php.net: array(2) {
543  ["scheme"]=>
544  string(4) "nntp"
545  ["host"]=>
546  string(12) "news.php.net"
547}
548
549--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) {
550  ["scheme"]=>
551  string(3) "ftp"
552  ["host"]=>
553  string(11) "ftp.gnu.org"
554  ["path"]=>
555  string(22) "/gnu/glic/glibc.tar.gz"
556}
557
558--> zlib:http://foo@bar: array(2) {
559  ["scheme"]=>
560  string(4) "zlib"
561  ["path"]=>
562  string(14) "http://foo@bar"
563}
564
565--> zlib:filename.txt: array(2) {
566  ["scheme"]=>
567  string(4) "zlib"
568  ["path"]=>
569  string(12) "filename.txt"
570}
571
572--> zlib:/path/to/my/file/file.txt: array(2) {
573  ["scheme"]=>
574  string(4) "zlib"
575  ["path"]=>
576  string(25) "/path/to/my/file/file.txt"
577}
578
579--> foo://foo@bar: array(3) {
580  ["scheme"]=>
581  string(3) "foo"
582  ["host"]=>
583  string(3) "bar"
584  ["user"]=>
585  string(3) "foo"
586}
587
588--> mailto:me@mydomain.com: array(2) {
589  ["scheme"]=>
590  string(6) "mailto"
591  ["path"]=>
592  string(15) "me@mydomain.com"
593}
594
595--> /foo.php?a=b&c=d: array(2) {
596  ["path"]=>
597  string(8) "/foo.php"
598  ["query"]=>
599  string(7) "a=b&c=d"
600}
601
602--> foo.php?a=b&c=d: array(2) {
603  ["path"]=>
604  string(7) "foo.php"
605  ["query"]=>
606  string(7) "a=b&c=d"
607}
608
609--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) {
610  ["scheme"]=>
611  string(4) "http"
612  ["host"]=>
613  string(15) "www.example.com"
614  ["port"]=>
615  int(8080)
616  ["user"]=>
617  string(4) "user"
618  ["pass"]=>
619  string(6) "passwd"
620  ["query"]=>
621  string(12) "bar=1&boom=0"
622}
623
624--> file:///path/to/file: array(2) {
625  ["scheme"]=>
626  string(4) "file"
627  ["path"]=>
628  string(13) "/path/to/file"
629}
630
631--> file://path/to/file: array(3) {
632  ["scheme"]=>
633  string(4) "file"
634  ["host"]=>
635  string(4) "path"
636  ["path"]=>
637  string(8) "/to/file"
638}
639
640--> file:/path/to/file: array(2) {
641  ["scheme"]=>
642  string(4) "file"
643  ["path"]=>
644  string(13) "/path/to/file"
645}
646
647--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) {
648  ["scheme"]=>
649  string(4) "http"
650  ["host"]=>
651  string(7) "1.2.3.4"
652  ["path"]=>
653  string(8) "/abc.asp"
654  ["query"]=>
655  string(7) "a=1&b=2"
656}
657
658--> http://foo.com#bar: array(3) {
659  ["scheme"]=>
660  string(4) "http"
661  ["host"]=>
662  string(7) "foo.com"
663  ["fragment"]=>
664  string(3) "bar"
665}
666
667--> scheme:: array(1) {
668  ["scheme"]=>
669  string(6) "scheme"
670}
671
672--> foo+bar://baz@bang/bla: array(4) {
673  ["scheme"]=>
674  string(7) "foo+bar"
675  ["host"]=>
676  string(4) "bang"
677  ["user"]=>
678  string(3) "baz"
679  ["path"]=>
680  string(4) "/bla"
681}
682
683--> gg:9130731: array(2) {
684  ["scheme"]=>
685  string(2) "gg"
686  ["path"]=>
687  string(7) "9130731"
688}
689
690--> http://user:@pass@host/path?argument?value#etc: array(7) {
691  ["scheme"]=>
692  string(4) "http"
693  ["host"]=>
694  string(4) "host"
695  ["user"]=>
696  string(4) "user"
697  ["pass"]=>
698  string(5) "@pass"
699  ["path"]=>
700  string(5) "/path"
701  ["query"]=>
702  string(14) "argument?value"
703  ["fragment"]=>
704  string(3) "etc"
705}
706
707--> http://10.10.10.10/:80: array(3) {
708  ["scheme"]=>
709  string(4) "http"
710  ["host"]=>
711  string(11) "10.10.10.10"
712  ["path"]=>
713  string(4) "/:80"
714}
715
716--> http://x:?: array(2) {
717  ["scheme"]=>
718  string(4) "http"
719  ["host"]=>
720  string(1) "x"
721}
722
723--> x:blah.com: array(2) {
724  ["scheme"]=>
725  string(1) "x"
726  ["path"]=>
727  string(8) "blah.com"
728}
729
730--> x:/blah.com: array(2) {
731  ["scheme"]=>
732  string(1) "x"
733  ["path"]=>
734  string(9) "/blah.com"
735}
736
737--> x://::abc/?: bool(false)
738
739--> http://::?: array(2) {
740  ["scheme"]=>
741  string(4) "http"
742  ["host"]=>
743  string(1) ":"
744}
745
746--> x://::6.5: array(3) {
747  ["scheme"]=>
748  string(1) "x"
749  ["host"]=>
750  string(1) ":"
751  ["port"]=>
752  int(6)
753}
754
755--> http://?:/: array(3) {
756  ["scheme"]=>
757  string(4) "http"
758  ["host"]=>
759  string(1) "?"
760  ["path"]=>
761  string(1) "/"
762}
763
764--> http://@?:/: array(4) {
765  ["scheme"]=>
766  string(4) "http"
767  ["host"]=>
768  string(1) "?"
769  ["user"]=>
770  string(0) ""
771  ["path"]=>
772  string(1) "/"
773}
774
775--> file:///:: array(2) {
776  ["scheme"]=>
777  string(4) "file"
778  ["path"]=>
779  string(2) "/:"
780}
781
782--> file:///a:/: array(2) {
783  ["scheme"]=>
784  string(4) "file"
785  ["path"]=>
786  string(3) "a:/"
787}
788
789--> file:///ab:/: array(2) {
790  ["scheme"]=>
791  string(4) "file"
792  ["path"]=>
793  string(5) "/ab:/"
794}
795
796--> file:///a:/: array(2) {
797  ["scheme"]=>
798  string(4) "file"
799  ["path"]=>
800  string(3) "a:/"
801}
802
803--> file:///@:/: array(2) {
804  ["scheme"]=>
805  string(4) "file"
806  ["path"]=>
807  string(3) "@:/"
808}
809
810--> file:///:80/: array(2) {
811  ["scheme"]=>
812  string(4) "file"
813  ["path"]=>
814  string(5) "/:80/"
815}
816
817--> []: array(1) {
818  ["path"]=>
819  string(2) "[]"
820}
821
822--> http://[x:80]/: array(3) {
823  ["scheme"]=>
824  string(4) "http"
825  ["host"]=>
826  string(6) "[x:80]"
827  ["path"]=>
828  string(1) "/"
829}
830
831--> : array(1) {
832  ["path"]=>
833  string(0) ""
834}
835
836--> /: array(1) {
837  ["path"]=>
838  string(1) "/"
839}
840
841--> http:///blah.com: bool(false)
842
843--> http://:80: bool(false)
844
845--> http://user@:80: bool(false)
846
847--> http://user:pass@:80: bool(false)
848
849--> http://:: bool(false)
850
851--> http://@/: bool(false)
852
853--> http://@:/: bool(false)
854
855--> http://:/: bool(false)
856
857--> http://?: bool(false)
858
859--> http://?:: bool(false)
860
861--> http://:?: bool(false)
862
863--> http://blah.com:123456: bool(false)
864
865--> http://blah.com:abcdef: bool(false)
866Done