3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php if (PHP_VERSION != '5.3.6') { die("Incorrect version"); } function a($url) { preg_match('!(?:(\w+)://)?(?:(\w+)\:(\w+)@)?([^/:]+)?(?:\:(\d*))?([^#?]+)?(?:\?([^#]+))?(?:#(.+$))?!i', $url, $out); return $out; } function b($url) { $out = parse_url($url); return $out; } $i = 100000; $start = microtime(true); while (--$i) { $u[1] = a('example.com'); $u[2] = a('example.com/index.php'); $u[3] = a('example.com?foo=bar'); $u[4] = a('/index.php'); $u[5] = a('/index.php/?foo=bar'); $u[6] = a('?foo=bar'); } print_r($u); echo microtime(true) - $start . "\n"; $i = 100000; $start = microtime(true); while (--$i) { $u[1] = b('example.com'); $u[2] = b('example.com/index.php'); $u[3] = b('example.com?foo=bar'); $u[4] = b('/index.php'); $u[5] = b('/index.php/?foo=bar'); $u[6] = b('?foo=bar'); } print_r($u); echo microtime(true) - $start . "\n";
based on FsT6Y
Output for 4.3.0 - 5.3.5, 5.3.7 - 7.2.0
Incorrect version
Output for 5.3.6
Array ( [1] => Array ( [0] => example.com [1] => [2] => [3] => [4] => example.com ) [2] => Array ( [0] => example.com/index.php [1] => [2] => [3] => [4] => example.com [5] => [6] => /index.php ) [3] => Array ( [0] => example.com?foo=bar [1] => [2] => [3] => [4] => example.com?foo=bar ) [4] => Array ( [0] => /index.php [1] => [2] => [3] => [4] => [5] => [6] => /index.php ) [5] => Array ( [0] => /index.php/?foo=bar [1] => [2] => [3] => [4] => [5] => [6] => /index.php/ [7] => foo=bar ) [6] => Array ( [0] => ?foo=bar [1] => [2] => [3] => [4] => ?foo=bar ) ) 1.2550489902496 Array ( [1] => Array ( [path] => example.com ) [2] => Array ( [path] => example.com/index.php ) [3] => Array ( [path] => example.com [query] => foo=bar ) [4] => Array ( [path] => /index.php ) [5] => Array ( [path] => /index.php/ [query] => foo=bar ) [6] => Array ( [query] => foo=bar ) ) 0.34682893753052