3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Because PHP_URL_* constants are sequential :-( const URL_SCHEME = 0x01; const URL_USER = 0x02; const URL_PASS = 0x04; const URL_HOST = 0x08; const URL_PORT = 0x10; const URL_PATH = 0x20; const URL_QUERY = 0x40; const URL_FRAGMENT = 0x80; function url_replace($url, $component, callable $callback) { $map = [ URL_SCHEME => 'scheme', URL_USER => 'user', URL_PASS => 'pass', URL_HOST => 'host', URL_PORT => 'port', URL_PATH => 'path', URL_QUERY => 'query', URL_FRAGMENT => 'fragment', ]; if (!$parts = parse_url($url)) { return $url; } foreach ($map as $component => $key) { if ($components & $flag) { $parts[$key] = $callback($parts[$key], $component); } } $result = ''; if (isset($parts['scheme'])) { $result = $parts['scheme'] . ':'; } if (isset($parts['host'])) { $result .= '//'; if (isset($parts['user'])) { $result .= $parts['user']; if (isset($parts['pass'])) { $result .= ':' . $parts['pass']; } $result .= '@'; } $result .= $parts['host']; if (isset($parts['port'])) { $result .= ':' . $parts['port']; } } if (isset($parts['path'])) { $result . = $parts['path']; } if (isset($parts['query'])) { $result . = $parts['query']; } if (isset($parts['fragment'])) { $result . = $parts['fragment']; } return $result; } $url = 'http://test.com/test-one,two three?a=b#bla'; echo url_replace($url, URL_PATH, function($path) { return '/foobar'; });

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.190.0180.04312.41
5.4.180.0150.04412.41
5.4.170.0190.04312.42
5.4.160.0170.04612.41
5.4.150.0210.04112.41
5.4.140.0130.04612.10
5.4.130.0150.04612.07
5.4.120.0190.03912.04
5.4.110.0160.04212.04
5.4.100.0180.05712.04
5.4.90.0190.04112.04
5.4.80.0150.04312.04
5.4.70.0180.04012.03
5.4.60.0160.04312.03
5.4.50.0160.04312.04
5.4.40.0190.05612.02
5.4.30.0200.03912.02
5.4.20.0160.04612.01
5.4.10.0230.05212.02
5.4.00.0230.06511.51
5.3.270.0180.04612.72
5.3.260.0130.04912.72
5.3.250.0190.05712.72
5.3.240.0200.04312.72
5.3.230.0170.04712.71
5.3.220.0230.04212.68
5.3.210.0180.04712.68
5.3.200.0190.04612.68
5.3.190.0230.04312.68
5.3.180.0180.04412.67
5.3.170.0180.04512.67
5.3.160.0130.05212.67
5.3.150.0200.04512.68
5.3.140.0320.06312.66
5.3.130.0200.04812.66
5.3.120.0180.04612.66
5.3.110.0220.04612.66
5.3.100.0250.05212.12
5.3.90.0150.04812.10
5.3.80.0180.04612.09
5.3.70.0170.04612.09
5.3.60.0190.04812.07
5.3.50.0210.05812.02
5.3.40.0210.05812.02
5.3.30.0150.04911.99
5.3.20.0270.06811.77
5.3.10.0150.04511.72
5.3.00.0200.04111.71

preferences:
142.29 ms | 1394 KiB | 7 Q