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