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