3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $url = 'http://username:password@hostname/path?arg=value&key=value2#anchor'; $ss_url_args = parse_url($url, PHP_URL_QUERY); echo $ss_url_args; $pieces = explode("&", $ss_url_args); for($i = 0; $i < count($peices); $i++) { $args = explode("=", $peices[$i]); if($args[0] === 'key') { $key = $args[1]; } } echo $key;
Output for 5.1.2 - 5.6.22, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
arg=value&key=value2 Notice: Undefined variable: peices in /in/v5Z8p on line 8 Notice: Undefined variable: key in /in/v5Z8p on line 16
Output for 5.0.4 - 5.1.1
Notice: Use of undefined constant PHP_URL_QUERY - assumed 'PHP_URL_QUERY' in /in/v5Z8p on line 5 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/v5Z8p on line 5 Notice: Undefined variable: peices in /in/v5Z8p on line 8 Notice: Undefined variable: key in /in/v5Z8p on line 16
Output for 4.3.0 - 5.0.3
Notice: Use of undefined constant PHP_URL_QUERY - assumed 'PHP_URL_QUERY' in /in/v5Z8p on line 5 Warning: parse_url() expects exactly 1 parameter, 2 given in /in/v5Z8p on line 5 Notice: Undefined variable: peices in /in/v5Z8p on line 8 Notice: Undefined variable: key in /in/v5Z8p on line 16