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