3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 为避免污染全局命名空间,已对所有标识符加 `e` 前缀 /** * 运行模式 * * debug 调试模式, 会开启详细的日志记录和错误提示 * * default 默认模式, 会输出错误提示 * * production 生产模式, 不会执行任何额外操作, 最高效地执行代码 */ const eDebug = 2; const eDefault = 1; const eProduction = 0; const eRunMode = eDefault; // 默认关掉所有错误提示 error_reporting(0); // 如果是默认模式,打开致命错误和解析错误的报告 if(eRunMode >= eDefault) error_reporting(E_ERROR | E_PARSE); // 如果是调试模式,打开全部错误提示,并启用修改建议提示 if(eRunMode >= eDebug) error_reporting(E_ALL | E_STRICT); class ePHPException extends Exception { protected $severity; protected $varList; public function __construct($message = "", $code = 0, $severity = 1, $filename = __FILE__, $lineno = __LINE__, Exception $previous = null, $varList = []) { $this->severity = $severity; $this->file = $filename; $this->line = $lineno; $this->varList = $varList; parent::__construct($message, $code, $previous); } public function getSeverity() { return $this->severity; } public function getVarList() { return $this->varList; } } set_error_handler(function($no, $str, $file, $line, $varList) { throw new ePHPException($str, 0, $no, $file, $line, null, $varList); }); if(eRunMode <= eProduction) { set_exception_handler(function(Exception $exception) { header("Content-Type: text/plant; charset=UTF-8"); die(header("HTTP/1.1 500 Internal Server Error")); }); } else { set_exception_handler(function(Exception $exception) { // 暂时我们只打算以纯文本的形式展示信息 header("Content-Type: text/plant; charset=UTF-8"); // 整体模版 $msg = "Exception `%s`: %s\nStack trace:\n%s\n thrown in %s on line %s"; // 栈的每一行的模版 $traceline = "#%s %s (%s): %s(%s)"; // 从异常对象获取运行栈 $trace = $exception->getTrace(); // 只有在调试模式才会显示参数的值,其他模式下只显示参数类型 if(eRunMode < eDebug) foreach ($trace as $key => $stackPoint) $trace[$key]['args'] = array_map('gettype', $trace[$key]['args']); $result = []; // 对运行栈的每一项应用模版 foreach ($trace as $key => $stackPoint) $result[] = sprintf( $traceline, $key, $stackPoint['file'], $stackPoint['line'], $stackPoint['function'], implode(', ', $stackPoint['args']) ); $result[] = '#' . ++$key . ' {main}'; // 应用整体模版 $msg = sprintf( $msg, get_class($exception), $exception->getMessage(), implode("\n", $result), $exception->getFile(), $exception->getLine() ); // 打印运行栈等信息 print $msg; // 如果当前是调试模式,且异常对象是我们构造的 ePHPException 类型,打印符号表 if(eRunMode >= eDebug && $exception instanceof ePHPException) print_r($exception->getVarList()); }); }

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)
8.3.60.0130.01018.18
8.3.50.0100.01021.21
8.3.40.0060.01518.63
8.3.30.0090.00620.29
8.3.20.0030.00620.46
8.3.10.0000.00820.92
8.3.00.0000.01121.80
8.2.180.0180.00418.04
8.2.170.0130.01022.96
8.2.160.0060.01620.35
8.2.150.0030.00624.18
8.2.140.0030.00524.66
8.2.130.0040.00426.16
8.2.120.0070.00021.11
8.2.110.0040.00419.31
8.2.100.0040.00817.72
8.2.90.0030.00519.02
8.2.80.0050.00317.97
8.2.70.0030.00517.49
8.2.60.0030.00617.91
8.2.50.0040.00418.07
8.2.40.0000.00818.13
8.2.30.0070.00019.42
8.2.20.0000.00917.64
8.2.10.0040.00417.67
8.2.00.0000.00817.57
8.1.280.0110.00725.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0080.00028.09
8.1.240.0030.00623.79
8.1.230.0110.00020.97
8.1.220.0000.00818.77
8.1.210.0030.00819.14
8.1.200.0060.00317.35
8.1.190.0040.00417.54
8.1.180.0030.00618.10
8.1.170.0030.00518.83
8.1.160.0000.00818.96
8.1.150.0040.00418.60
8.1.140.0080.00017.49
8.1.130.0040.00417.75
8.1.120.0040.00417.53
8.1.110.0000.00717.34
8.1.100.0030.00517.46
8.1.90.0030.00517.50
8.1.80.0070.00017.42
8.1.70.0040.00417.42
8.1.60.0040.00417.60
8.1.50.0050.00317.48
8.1.40.0030.00617.43
8.1.30.0040.00417.57
8.1.20.0040.00417.54
8.1.10.0000.00817.46
8.1.00.0060.00317.43
8.0.300.0040.00420.00
8.0.290.0040.00417.30
8.0.280.0040.00418.45
8.0.270.0030.00517.20
8.0.260.0030.00316.84
8.0.250.0060.00316.94
8.0.240.0060.00316.88
8.0.230.0000.00716.93
8.0.220.0000.00716.91
8.0.210.0000.00716.90
8.0.200.0030.00316.84
8.0.190.0060.00316.95
8.0.180.0000.00816.98
8.0.170.0040.00416.86
8.0.160.0040.00416.82
8.0.150.0040.00416.86
8.0.140.0040.00416.88
8.0.130.0000.00513.34
8.0.120.0000.00816.89
8.0.110.0000.00716.90
8.0.100.0000.00716.88
8.0.90.0040.00416.76
8.0.80.0100.00716.84
8.0.70.0000.00816.76
8.0.60.0040.00416.88
8.0.50.0000.00816.75
8.0.30.0060.01517.15
8.0.20.0140.00517.40
8.0.10.0080.00017.02
8.0.00.0110.00716.80
7.4.330.0060.00016.84
7.4.320.0040.00416.40
7.4.300.0050.00216.55
7.4.290.0030.00316.47
7.4.280.0040.00416.39
7.4.270.0030.00316.54
7.4.260.0030.00313.16
7.4.250.0040.00416.46
7.4.240.0040.00416.60
7.4.230.0040.00416.68
7.4.220.0120.00616.53
7.4.210.0090.00716.54
7.4.200.0040.00416.41
7.4.190.0000.00716.67
7.4.160.0070.01016.27
7.4.150.0280.02517.40
7.4.140.0100.00717.86
7.4.130.0080.01016.53
7.4.120.0100.01016.45
7.4.110.0070.01016.68
7.4.100.0070.01016.58
7.4.90.0090.01216.60
7.4.80.0070.01119.39
7.4.70.0040.01816.64
7.4.60.0140.00316.62
7.4.50.0030.00616.43
7.4.40.0120.00322.77
7.4.30.0090.00916.71
7.4.00.0080.00415.14
7.3.330.0000.00513.21
7.3.320.0000.00813.21
7.3.310.0030.00316.29
7.3.300.0000.00716.27
7.3.290.0090.00616.27
7.3.280.0080.01016.31
7.3.270.0130.01017.40
7.3.260.0100.00818.24
7.3.250.0080.01216.57
7.3.240.0090.00916.56
7.3.230.0120.00416.39
7.3.210.0120.00616.27
7.3.200.0080.01119.39
7.3.190.0120.00616.34
7.3.180.0100.00716.29
7.3.170.0060.01016.27
7.3.160.0120.00416.36
7.3.120.0110.00414.67
7.3.10.0280.00316.48
7.3.00.0090.00816.31
7.2.330.0190.00416.74
7.2.320.0060.01616.56
7.2.310.0090.00916.76
7.2.300.0100.00716.83
7.2.290.0090.00616.78
7.2.130.0100.01016.30
7.2.120.0240.00516.57
7.2.110.0160.01216.27
7.2.100.0150.01116.12
7.2.90.0160.01616.54
7.2.80.0250.00416.24
7.2.70.0150.01516.44
7.2.60.0120.00916.56
7.2.50.0110.01416.61
7.2.40.0160.00916.24
7.2.30.0130.01316.33
7.2.20.0140.01116.49
7.2.10.0200.00816.47
7.2.00.0060.00617.97
7.1.250.0110.01115.09
7.1.200.0060.00615.40
7.1.100.0130.00317.85
7.1.70.0000.00817.01
7.1.60.0070.01719.17
7.1.50.0030.02116.91
7.1.00.0030.05722.28
7.0.200.0070.00016.69
7.0.140.0000.08022.01
7.0.80.0030.10020.00
7.0.70.0170.07319.99
7.0.60.0070.08719.98
7.0.50.0030.07720.21
7.0.40.0170.08020.08
7.0.30.0070.07020.08
7.0.20.0070.07020.09
7.0.10.0230.05720.03
7.0.00.0000.04720.08
5.6.280.0000.08020.94
5.6.230.0070.04720.62
5.6.220.0400.05720.59
5.6.210.0130.06020.66
5.6.200.0100.07721.12
5.6.190.0030.07721.11
5.6.180.0070.07721.14
5.6.170.0200.06721.07
5.6.160.0030.06321.20
5.6.150.0170.08021.07
5.6.140.0070.04020.99
5.6.130.0030.05321.04
5.6.120.0100.03720.98
5.6.110.0030.05021.16
5.6.100.0030.07321.16
5.6.90.0030.04321.18
5.6.80.0030.05720.37
5.6.70.0130.06020.38
5.6.60.0070.03320.51
5.6.50.0030.06720.55
5.6.40.0000.04720.38
5.6.30.0000.04720.53
5.6.20.0000.04020.48
5.6.10.0100.05320.52
5.6.00.0030.04020.49
5.5.370.0070.06020.45
5.5.360.0030.05720.46
5.5.350.0070.08020.41
5.5.340.0100.08020.66
5.5.330.0070.08020.76
5.5.320.0200.06720.93
5.5.310.0130.04720.76
5.5.300.0100.03720.93
5.5.290.0130.04020.83
5.5.280.0100.08020.67
5.5.270.0100.03720.82
5.5.260.0070.04020.92
5.5.250.0030.07020.57
5.5.240.0030.05020.30
5.5.230.0070.06020.17
5.5.220.0000.04320.27
5.5.210.0000.04020.30
5.5.200.0030.05020.18
5.5.190.0030.04020.27
5.5.180.0030.04020.14
5.5.160.0000.04020.21
5.5.150.0000.05320.20
5.5.140.0100.03320.27
5.5.130.0100.03320.21
5.5.120.0030.04020.26
5.5.110.0030.04720.02
5.5.100.0070.04020.19
5.5.90.0030.04019.97
5.5.80.0030.03320.15
5.5.70.0070.03720.03
5.5.60.0070.04020.11
5.5.50.0030.05020.10
5.5.40.0030.04020.14
5.5.30.0100.06019.98
5.5.20.0130.07320.08
5.5.10.0130.06720.07
5.5.00.0100.08020.07
5.4.450.0130.04319.21
5.4.440.0070.03319.18
5.4.430.0000.04719.57
5.4.420.0030.04319.53
5.4.410.0000.04019.10
5.4.400.0100.03319.23
5.4.390.0100.04319.14
5.4.380.0030.05719.16
5.4.370.0070.06718.91
5.4.360.0000.04319.05
5.4.350.0000.04019.03
5.4.340.0100.03319.01
5.4.320.0100.05019.09
5.4.310.0000.04019.13
5.4.300.0100.03719.13
5.4.290.0070.03319.04
5.4.280.0070.03719.02
5.4.270.0000.04019.13
5.4.260.0030.03318.88
5.4.250.0030.03719.13
5.4.240.0070.03318.94
5.4.230.0000.04019.04
5.4.220.0030.04019.08
5.4.210.0030.03318.87
5.4.200.0070.03019.06
5.4.190.0000.08019.11
5.4.180.0070.07719.12
5.4.170.0030.08319.11
5.4.160.0070.07719.11
5.4.150.0100.07719.12
5.4.140.0100.06716.47
5.4.130.0100.07016.48
5.4.120.0070.07016.38
5.4.110.0070.06316.44
5.4.100.0030.07716.51
5.4.90.0070.06716.56
5.4.80.0030.07716.38
5.4.70.0100.06716.51
5.4.60.0030.07716.27
5.4.50.0070.07016.27
5.4.40.0100.07316.44
5.4.30.0070.07016.45
5.4.20.0030.06716.41
5.4.10.0030.07716.45
5.4.00.0070.04715.66
5.3.290.0000.03714.79
5.3.280.0030.03714.57
5.3.270.0100.07014.62
5.3.260.0100.07014.58
5.3.250.0100.07314.54
5.3.240.0030.07714.73
5.3.230.0200.06014.55
5.3.220.0030.07314.52
5.3.210.0030.08314.59
5.3.200.0030.08014.71
5.3.190.0030.04014.51
5.3.180.0070.07014.67
5.3.170.0030.07014.52
5.3.160.0000.05314.59
5.3.150.0030.07714.56
5.3.140.0100.05314.65
5.3.130.0070.08314.48
5.3.120.0100.07714.58
5.3.110.0070.07714.67
5.3.100.0170.06014.10
5.3.90.0030.05014.16
5.3.80.0100.07013.96
5.3.70.0070.04714.01
5.3.60.0030.04713.94
5.3.50.0030.06314.01
5.3.40.0000.05314.04
5.3.30.0070.07313.81
5.3.20.0070.07313.80
5.3.10.0100.06013.66
5.3.00.0070.06013.76
5.2.170.0000.05011.60
5.2.160.0130.05311.60
5.2.150.0030.06311.60
5.2.140.0030.06011.60
5.2.130.0070.03711.60
5.2.120.0000.04711.60
5.2.110.0100.02711.60
5.2.100.0070.05711.60
5.2.90.0100.05711.60
5.2.80.0100.04711.60
5.2.70.0070.06711.60
5.2.60.0030.06311.60
5.2.50.0070.04011.60
5.2.40.0070.05711.60
5.2.30.0000.06011.60
5.2.20.0100.06011.60
5.2.10.0000.06311.60
5.2.00.0000.06711.60
5.1.60.0100.04711.60
5.1.50.0000.04311.60
5.1.40.0070.04711.60
5.1.30.0030.06011.60
5.1.20.0170.05011.60
5.1.10.0000.05011.60
5.1.00.0070.04311.60
5.0.50.0030.05011.60
5.0.40.0000.04711.60
5.0.30.0000.06311.60
5.0.20.0070.04011.60
5.0.10.0100.03311.60
5.0.00.0030.06311.60
4.4.90.0030.03711.60
4.4.80.0030.01711.60
4.4.70.0030.02711.60
4.4.60.0000.03711.60
4.4.50.0030.03311.60
4.4.40.0030.05011.60
4.4.30.0030.03311.60
4.4.20.0070.03011.60
4.4.10.0070.03311.60
4.4.00.0000.04711.60
4.3.110.0100.02711.60
4.3.100.0000.03711.60
4.3.90.0030.03311.60
4.3.80.0030.05011.60
4.3.70.0030.02311.60
4.3.60.0030.03011.60
4.3.50.0030.03311.60
4.3.40.0000.04011.60
4.3.30.0030.02011.60
4.3.20.0000.02311.60
4.3.10.0000.03711.60
4.3.00.0000.03011.60

preferences:
45.83 ms | 401 KiB | 5 Q