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(7) {
458  ["scheme"]=>
459  string(4) "http"
460  ["host"]=>
461  string(11) "www.php.net"
462  ["user"]=>
463  string(6) "secret"
464  ["pass"]=>
465  string(0) ""
466  ["path"]=>
467  string(10) "/index.php"
468  ["query"]=>
469  string(31) "test=1&test2=char&test3=mixesCI"
470  ["fragment"]=>
471  string(16) "some_page_ref123"
472}
473
474--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
475  ["scheme"]=>
476  string(4) "http"
477  ["host"]=>
478  string(11) "www.php.net"
479  ["port"]=>
480  int(80)
481  ["user"]=>
482  string(0) ""
483  ["pass"]=>
484  string(7) "hideout"
485  ["path"]=>
486  string(10) "/index.php"
487  ["query"]=>
488  string(31) "test=1&test2=char&test3=mixesCI"
489  ["fragment"]=>
490  string(16) "some_page_ref123"
491}
492
493--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
494  ["scheme"]=>
495  string(4) "http"
496  ["host"]=>
497  string(11) "www.php.net"
498  ["user"]=>
499  string(6) "secret"
500  ["pass"]=>
501  string(7) "hideout"
502  ["path"]=>
503  string(10) "/index.php"
504  ["query"]=>
505  string(31) "test=1&test2=char&test3=mixesCI"
506  ["fragment"]=>
507  string(16) "some_page_ref123"
508}
509
510--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(7) {
511  ["scheme"]=>
512  string(4) "http"
513  ["host"]=>
514  string(11) "www.php.net"
515  ["port"]=>
516  int(80)
517  ["user"]=>
518  string(14) "secret@hideout"
519  ["path"]=>
520  string(10) "/index.php"
521  ["query"]=>
522  string(31) "test=1&test2=char&test3=mixesCI"
523  ["fragment"]=>
524  string(16) "some_page_ref123"
525}
526
527--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123: array(8) {
528  ["scheme"]=>
529  string(4) "http"
530  ["host"]=>
531  string(11) "www.php.net"
532  ["port"]=>
533  int(80)
534  ["user"]=>
535  string(6) "secret"
536  ["pass"]=>
537  string(7) "hid:out"
538  ["path"]=>
539  string(10) "/index.php"
540  ["query"]=>
541  string(31) "test=1&test2=char&test3=mixesCI"
542  ["fragment"]=>
543  string(16) "some_page_ref123"
544}
545
546--> nntp://news.php.net: array(2) {
547  ["scheme"]=>
548  string(4) "nntp"
549  ["host"]=>
550  string(12) "news.php.net"
551}
552
553--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz: array(3) {
554  ["scheme"]=>
555  string(3) "ftp"
556  ["host"]=>
557  string(11) "ftp.gnu.org"
558  ["path"]=>
559  string(22) "/gnu/glic/glibc.tar.gz"
560}
561
562--> zlib:http://foo@bar: array(2) {
563  ["scheme"]=>
564  string(4) "zlib"
565  ["path"]=>
566  string(14) "http://foo@bar"
567}
568
569--> zlib:filename.txt: array(2) {
570  ["scheme"]=>
571  string(4) "zlib"
572  ["path"]=>
573  string(12) "filename.txt"
574}
575
576--> zlib:/path/to/my/file/file.txt: array(2) {
577  ["scheme"]=>
578  string(4) "zlib"
579  ["path"]=>
580  string(25) "/path/to/my/file/file.txt"
581}
582
583--> foo://foo@bar: array(3) {
584  ["scheme"]=>
585  string(3) "foo"
586  ["host"]=>
587  string(3) "bar"
588  ["user"]=>
589  string(3) "foo"
590}
591
592--> mailto:me@mydomain.com: array(2) {
593  ["scheme"]=>
594  string(6) "mailto"
595  ["path"]=>
596  string(15) "me@mydomain.com"
597}
598
599--> /foo.php?a=b&c=d: array(2) {
600  ["path"]=>
601  string(8) "/foo.php"
602  ["query"]=>
603  string(7) "a=b&c=d"
604}
605
606--> foo.php?a=b&c=d: array(2) {
607  ["path"]=>
608  string(7) "foo.php"
609  ["query"]=>
610  string(7) "a=b&c=d"
611}
612
613--> http://user:passwd@www.example.com:8080?bar=1&boom=0: array(6) {
614  ["scheme"]=>
615  string(4) "http"
616  ["host"]=>
617  string(15) "www.example.com"
618  ["port"]=>
619  int(8080)
620  ["user"]=>
621  string(4) "user"
622  ["pass"]=>
623  string(6) "passwd"
624  ["query"]=>
625  string(12) "bar=1&boom=0"
626}
627
628--> file:///path/to/file: array(2) {
629  ["scheme"]=>
630  string(4) "file"
631  ["path"]=>
632  string(13) "/path/to/file"
633}
634
635--> file://path/to/file: array(3) {
636  ["scheme"]=>
637  string(4) "file"
638  ["host"]=>
639  string(4) "path"
640  ["path"]=>
641  string(8) "/to/file"
642}
643
644--> file:/path/to/file: array(2) {
645  ["scheme"]=>
646  string(4) "file"
647  ["path"]=>
648  string(13) "/path/to/file"
649}
650
651--> http://1.2.3.4:/abc.asp?a=1&b=2: array(4) {
652  ["scheme"]=>
653  string(4) "http"
654  ["host"]=>
655  string(7) "1.2.3.4"
656  ["path"]=>
657  string(8) "/abc.asp"
658  ["query"]=>
659  string(7) "a=1&b=2"
660}
661
662--> http://foo.com#bar: array(3) {
663  ["scheme"]=>
664  string(4) "http"
665  ["host"]=>
666  string(7) "foo.com"
667  ["fragment"]=>
668  string(3) "bar"
669}
670
671--> scheme:: array(1) {
672  ["scheme"]=>
673  string(6) "scheme"
674}
675
676--> foo+bar://baz@bang/bla: array(4) {
677  ["scheme"]=>
678  string(7) "foo+bar"
679  ["host"]=>
680  string(4) "bang"
681  ["user"]=>
682  string(3) "baz"
683  ["path"]=>
684  string(4) "/bla"
685}
686
687--> gg:9130731: array(2) {
688  ["scheme"]=>
689  string(2) "gg"
690  ["path"]=>
691  string(7) "9130731"
692}
693
694--> http://user:@pass@host/path?argument?value#etc: array(7) {
695  ["scheme"]=>
696  string(4) "http"
697  ["host"]=>
698  string(4) "host"
699  ["user"]=>
700  string(4) "user"
701  ["pass"]=>
702  string(5) "@pass"
703  ["path"]=>
704  string(5) "/path"
705  ["query"]=>
706  string(14) "argument?value"
707  ["fragment"]=>
708  string(3) "etc"
709}
710
711--> http://10.10.10.10/:80: array(3) {
712  ["scheme"]=>
713  string(4) "http"
714  ["host"]=>
715  string(11) "10.10.10.10"
716  ["path"]=>
717  string(4) "/:80"
718}
719
720--> http://x:?: array(2) {
721  ["scheme"]=>
722  string(4) "http"
723  ["host"]=>
724  string(1) "x"
725}
726
727--> x:blah.com: array(2) {
728  ["scheme"]=>
729  string(1) "x"
730  ["path"]=>
731  string(8) "blah.com"
732}
733
734--> x:/blah.com: array(2) {
735  ["scheme"]=>
736  string(1) "x"
737  ["path"]=>
738  string(9) "/blah.com"
739}
740
741--> x://::abc/?: bool(false)
742
743--> http://::?: array(2) {
744  ["scheme"]=>
745  string(4) "http"
746  ["host"]=>
747  string(1) ":"
748}
749
750--> http://::#: array(2) {
751  ["scheme"]=>
752  string(4) "http"
753  ["host"]=>
754  string(1) ":"
755}
756
757--> x://::6.5: array(3) {
758  ["scheme"]=>
759  string(1) "x"
760  ["host"]=>
761  string(1) ":"
762  ["port"]=>
763  int(6)
764}
765
766--> http://?:/: bool(false)
767
768--> http://@?:/: bool(false)
769
770--> file:///:: array(2) {
771  ["scheme"]=>
772  string(4) "file"
773  ["path"]=>
774  string(2) "/:"
775}
776
777--> file:///a:/: array(2) {
778  ["scheme"]=>
779  string(4) "file"
780  ["path"]=>
781  string(3) "a:/"
782}
783
784--> file:///ab:/: array(2) {
785  ["scheme"]=>
786  string(4) "file"
787  ["path"]=>
788  string(5) "/ab:/"
789}
790
791--> file:///a:/: array(2) {
792  ["scheme"]=>
793  string(4) "file"
794  ["path"]=>
795  string(3) "a:/"
796}
797
798--> file:///@:/: array(2) {
799  ["scheme"]=>
800  string(4) "file"
801  ["path"]=>
802  string(3) "@:/"
803}
804
805--> file:///:80/: array(2) {
806  ["scheme"]=>
807  string(4) "file"
808  ["path"]=>
809  string(5) "/:80/"
810}
811
812--> []: array(1) {
813  ["path"]=>
814  string(2) "[]"
815}
816
817--> http://[x:80]/: array(3) {
818  ["scheme"]=>
819  string(4) "http"
820  ["host"]=>
821  string(6) "[x:80]"
822  ["path"]=>
823  string(1) "/"
824}
825
826--> : array(1) {
827  ["path"]=>
828  string(0) ""
829}
830
831--> /: array(1) {
832  ["path"]=>
833  string(1) "/"
834}
835
836--> /rest/Users?filter={"id":"123"}: array(2) {
837  ["path"]=>
838  string(11) "/rest/Users"
839  ["query"]=>
840  string(19) "filter={"id":"123"}"
841}
842
843--> http:///blah.com: bool(false)
844
845--> http://:80: bool(false)
846
847--> http://user@:80: bool(false)
848
849--> http://user:pass@:80: 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://?:: bool(false)
864
865--> http://:?: bool(false)
866
867--> http://blah.com:123456: bool(false)
868
869--> http://blah.com:abcdef: bool(false)
870Done
871