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