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