3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $pattern = <<<REGEXP ! ^ (?P<scheme> [a-z][a-z0-9+.\-]* ) [:] # scheme is mandatory, and followed by a : (?: [/][/] # // indicates that this component is the authority (?: (?P<user> [^:@/]+ ) (?: [:] (?P<pass> [^:@/]+ ) )? [@] )? # auth details are optional (?P<host> [^:/]* ) # host is mandatory. Technically it should be at least 1 char, but PHP has # internal schemes that violate this rule and as much as I dislike it, I # feel that we should pass this (?: [:] (?P<port> [0-9]+ ) )? # port is simply a sequence of decimal digits (?= [/?#]|$ ) # path must be missing or begin with / if authority is present )? (?P<path> [^?#]+ )? # path is everything up to the query/fragment (?: [?] (?P<query> [^#]+ )? # query is optional (?: [#] (?P<fragment> .+ )? # fragment is optional $ !xi REGEXP; $url = 'http://foo.com/test?thing=stuff#fragment'; preg_match($pattern, $url, $matches); print_r($matches);
Output for 5.2.3 - 7.1.0
Warning: preg_match(): Compilation failed: missing ) at offset 1064 in /in/D9QoH on line 36
Output for 5.2.0 - 5.2.2
<br /> <b>Warning</b>: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: missing ) at offset 1064 in <b>/in/D9QoH</b> on line <b>36</b><br />
Output for 4.4.3 - 5.1.1, 5.1.3 - 5.1.6
<br /> <b>Warning</b>: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: missing ) at offset 1064 in <b>/in/D9QoH</b> on line <b>36</b><br /> Array ( )
Output for 5.1.2
<br /> <b>Warning</b>: preg_match() [<a href='function.preg-match'>function.preg-match</a>]: Compilation failed: missing ) at offset 1064 in <b>/in/D9QoH</b> on line <b>37</b><br /> Array ( )
Output for 4.4.2
<br /> <b>Warning</b>: preg_match(): Compilation failed: missing ) at offset 1064 in <b>/in/D9QoH</b> on line <b>37</b><br /> Array ( )
Output for 4.3.11 - 4.4.1
<br /> <b>Warning</b>: preg_match(): Compilation failed: missing ) at offset 1064 in <b>/in/D9QoH</b> on line <b>36</b><br /> Array ( )
Output for 4.3.0 - 4.3.10
<br /> <b>Warning</b>: Compilation failed: missing ) at offset 1064 in <b>/in/D9QoH</b> on line <b>36</b><br /> Array ( )