3v4l.org

run code in 300+ PHP versions simultaneously
<?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";
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.5, 5.3.7 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.13, 7.3.0 - 7.3.1
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.4852020740509 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.51330590248108

preferences:
203.54 ms | 405 KiB | 288 Q