3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function addQuery($url,array $query) { $cache=parse_url($url,PHP_URL_QUERY); if(empty($cache)) return $url."?".http_build_query($query); else return $url."&".http_build_query($query); } $test=array("http://example.com/page/","http://example.com/page","http://example.com/?p=page"); print_r(array_map(function($v){ return addQuery($v,array("myquery"=>"string")); },$test));
Output for 5.3.0 - 5.6.21, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [0] => http://example.com/page/?myquery=string [1] => http://example.com/page?myquery=string [2] => http://example.com/?p=page&myquery=string )
Output for hhvm-3.10.0

Process exited with code 153.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/vMCKC on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/vMCKC on line 2
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in /in/vMCKC on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE or T_CONST in /in/vMCKC on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `'&'' or `T_VARIABLE' or `T_CONST' in /in/vMCKC on line 2
Process exited with code 255.