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