1--TEST--
2Test parse_url() function: Parse a load of URLs without specifying PHP_URL_PATH as the URL component
3--FILE--
4<?php
5/*
6 * Parse a load of URLs without specifying PHP_URL_PATH as the URL component
7 */
8include_once(__DIR__ . '/urls.inc');
9
10foreach ($urls as $url) {
11    echo "--> $url   : ";
12    var_dump(parse_url($url, PHP_URL_PATH));
13}
14
15echo "Done";
16?>
17--EXPECT--
18--> 64.246.30.37   : string(12) "64.246.30.37"
19--> http://64.246.30.37   : NULL
20--> http://64.246.30.37/   : string(1) "/"
21--> 64.246.30.37/   : string(13) "64.246.30.37/"
22--> 64.246.30.37:80/   : string(1) "/"
23--> php.net   : string(7) "php.net"
24--> php.net/   : string(8) "php.net/"
25--> http://php.net   : NULL
26--> http://php.net/   : string(1) "/"
27--> www.php.net   : string(11) "www.php.net"
28--> www.php.net/   : string(12) "www.php.net/"
29--> http://www.php.net   : NULL
30--> http://www.php.net/   : string(1) "/"
31--> www.php.net:80   : NULL
32--> http://www.php.net:80   : NULL
33--> http://www.php.net:80/   : string(1) "/"
34--> http://www.php.net/index.php   : string(10) "/index.php"
35--> www.php.net/?   : string(12) "www.php.net/"
36--> www.php.net:80/?   : string(1) "/"
37--> http://www.php.net/?   : string(1) "/"
38--> http://www.php.net:80/?   : string(1) "/"
39--> http://www.php.net:80/index.php   : string(10) "/index.php"
40--> http://www.php.net:80/foo/bar/index.php   : string(18) "/foo/bar/index.php"
41--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php   : string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
42--> 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   : string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
43--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/   : string(45) "/this/is/a/very/deep/directory/structure/and/"
44--> http://www.php.net:80/this/is/a/very/deep/directory/structure/and/file.php   : string(53) "/this/is/a/very/deep/directory/structure/and/file.php"
45--> http://www.php.net:80/this/../a/../deep/directory   : string(28) "/this/../a/../deep/directory"
46--> http://www.php.net:80/this/../a/../deep/directory/   : string(29) "/this/../a/../deep/directory/"
47--> http://www.php.net:80/this/is/a/very/deep/directory/../file.php   : string(42) "/this/is/a/very/deep/directory/../file.php"
48--> http://www.php.net:80/index.php   : string(10) "/index.php"
49--> http://www.php.net:80/index.php?   : string(10) "/index.php"
50--> http://www.php.net:80/#foo   : string(1) "/"
51--> http://www.php.net:80/?#   : string(1) "/"
52--> http://www.php.net:80/?test=1   : string(1) "/"
53--> http://www.php.net/?test=1&   : string(1) "/"
54--> http://www.php.net:80/?&   : string(1) "/"
55--> http://www.php.net:80/index.php?test=1&   : string(10) "/index.php"
56--> http://www.php.net/index.php?&   : string(10) "/index.php"
57--> http://www.php.net:80/index.php?foo&   : string(10) "/index.php"
58--> http://www.php.net/index.php?&foo   : string(10) "/index.php"
59--> http://www.php.net:80/index.php?test=1&test2=char&test3=mixesCI   : string(10) "/index.php"
60--> www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123   : string(10) "/index.php"
61--> http://secret@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123   : string(10) "/index.php"
62--> http://secret:@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123   : string(10) "/index.php"
63--> http://:hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123   : string(10) "/index.php"
64--> http://secret:hideout@www.php.net/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123   : string(10) "/index.php"
65--> http://secret@hideout@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123   : string(10) "/index.php"
66--> http://secret:hid:out@www.php.net:80/index.php?test=1&test2=char&test3=mixesCI#some_page_ref123   : string(10) "/index.php"
67--> nntp://news.php.net   : NULL
68--> ftp://ftp.gnu.org/gnu/glic/glibc.tar.gz   : string(22) "/gnu/glic/glibc.tar.gz"
69--> zlib:http://foo@bar   : string(14) "http://foo@bar"
70--> zlib:filename.txt   : string(12) "filename.txt"
71--> zlib:/path/to/my/file/file.txt   : string(25) "/path/to/my/file/file.txt"
72--> foo://foo@bar   : NULL
73--> mailto:me@mydomain.com   : string(15) "me@mydomain.com"
74--> /foo.php?a=b&c=d   : string(8) "/foo.php"
75--> foo.php?a=b&c=d   : string(7) "foo.php"
76--> http://user:passwd@www.example.com:8080?bar=1&boom=0   : NULL
77--> http://user_me-you:my_pas-word@www.example.com:8080?bar=1&boom=0   : NULL
78--> file:///path/to/file   : string(13) "/path/to/file"
79--> file://path/to/file   : string(8) "/to/file"
80--> file:/path/to/file   : string(13) "/path/to/file"
81--> http://1.2.3.4:/abc.asp?a=1&b=2   : string(8) "/abc.asp"
82--> http://foo.com#bar   : NULL
83--> scheme:   : NULL
84--> foo+bar://baz@bang/bla   : string(4) "/bla"
85--> gg:9130731   : string(7) "9130731"
86--> http://user:@pass@host/path?argument?value#etc   : string(5) "/path"
87--> http://10.10.10.10/:80   : string(4) "/:80"
88--> http://x:?   : NULL
89--> x:blah.com   : string(8) "blah.com"
90--> x:/blah.com   : string(9) "/blah.com"
91--> x://::abc/?   : bool(false)
92--> http://::?   : NULL
93--> http://::#   : NULL
94--> x://::6.5   : NULL
95--> http://?:/   : bool(false)
96--> http://@?:/   : bool(false)
97--> file:///:   : string(2) "/:"
98--> file:///a:/   : string(3) "a:/"
99--> file:///ab:/   : string(5) "/ab:/"
100--> file:///a:/   : string(3) "a:/"
101--> file:///@:/   : string(3) "@:/"
102--> file:///:80/   : string(5) "/:80/"
103--> []   : string(2) "[]"
104--> http://[x:80]/   : string(1) "/"
105-->    : string(0) ""
106--> /   : string(1) "/"
107--> /rest/Users?filter={"id":"123"}   : string(11) "/rest/Users"
108--> %:x   : string(3) "%:x"
109--> https://example.com:0/   : string(1) "/"
110--> http:///blah.com   : bool(false)
111--> http://:80   : bool(false)
112--> http://user@:80   : bool(false)
113--> http://user:pass@:80   : bool(false)
114--> http://:   : bool(false)
115--> http://@/   : bool(false)
116--> http://@:/   : bool(false)
117--> http://:/   : bool(false)
118--> http://?   : bool(false)
119--> http://#   : bool(false)
120--> http://?:   : bool(false)
121--> http://:?   : bool(false)
122--> http://blah.com:123456   : bool(false)
123--> http://blah.com:abcdef   : bool(false)
124Done
125