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 = eDebug; // 默认关掉所有错误提示 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 { echo 11; 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 . print_r($exception->getVarList(), true); // 如果当前是调试模式,且异常对象是我们构造的 ePHPException 类型,打印符号表 }); } class TypeException extends Exception{} function repeat($argInt, $argString) { if(is_int($argInt) && is_int($argString)) return str_repeat($argString, $argInt); else throw new TypeException("Type Error"); } function call($func, $arg1, $arg2) { $func($arg1, $arg2); } function errorFunc() { dontExistFunction(); } // 错误1: call("array_keys", 0, 0); // 错误2: //call("repeat", "Hello World", 1234); // 错误3: //call("errorFunc", 0, 0);

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.0090.00618.30
8.3.50.0040.01422.11
8.3.40.0110.00418.71
8.3.30.0070.00719.05
8.3.20.0050.00320.16
8.3.10.0040.00421.92
8.3.00.0040.00422.58
8.2.180.0100.01016.63
8.2.170.0120.00922.96
8.2.160.0110.00420.91
8.2.150.0000.00824.18
8.2.140.0000.00824.66
8.2.130.0000.00726.16
8.2.120.0040.00419.36
8.2.110.0030.00721.11
8.2.100.0120.00017.78
8.2.90.0050.00319.25
8.2.80.0040.00417.97
8.2.70.0090.00017.63
8.2.60.0080.00017.91
8.2.50.0080.00018.07
8.2.40.0030.00917.93
8.2.30.0080.00017.97
8.2.20.0000.00817.81
8.2.10.0040.00417.88
8.2.00.0030.00517.90
8.1.280.0090.00625.92
8.1.270.0040.00422.19
8.1.260.0070.00026.35
8.1.250.0080.00028.09
8.1.240.0030.00621.21
8.1.230.0120.00017.42
8.1.220.0050.00317.79
8.1.210.0060.00318.77
8.1.200.0090.00017.23
8.1.190.0040.00417.23
8.1.180.0000.00818.10
8.1.170.0030.00618.40
8.1.160.0040.00422.05
8.1.150.0000.00818.62
8.1.140.0000.00717.43
8.1.130.0040.00417.72
8.1.120.0080.00017.36
8.1.110.0040.00417.36
8.1.100.0000.00717.46
8.1.90.0000.00717.48
8.1.80.0070.00017.48
8.1.70.0000.00717.37
8.1.60.0030.00617.57
8.1.50.0080.00017.45
8.1.40.0030.00517.39
8.1.30.0070.00017.53
8.1.20.0040.00417.63
8.1.10.0080.00017.56
8.1.00.0030.00617.49
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0030.00318.37
8.0.270.0000.00717.30
8.0.260.0000.00616.92
8.0.250.0030.00316.99
8.0.240.0050.00217.05
8.0.230.0030.00316.95
8.0.220.0000.00816.98
8.0.210.0030.00316.99
8.0.200.0030.00316.95
8.0.190.0040.00317.13
8.0.180.0100.00016.95
8.0.170.0030.00617.07
8.0.160.0050.00216.95
8.0.150.0000.00717.03
8.0.140.0040.00416.82
8.0.130.0060.00013.41
8.0.120.0050.00316.90
8.0.110.0000.00716.92
8.0.100.0000.00816.89
8.0.90.0070.00017.00
8.0.80.0030.01617.05
8.0.70.0030.00516.92
8.0.60.0000.00716.90
8.0.50.0050.00216.94
8.0.30.0150.00717.04
8.0.20.0150.00517.40
8.0.10.0000.00817.00
8.0.00.0130.01016.80
7.4.330.0060.00015.02
7.4.320.0050.00316.53
7.4.300.0000.00616.57
7.4.290.0030.00316.54
7.4.280.0030.00316.66
7.4.270.0000.00816.64
7.4.260.0000.00816.58
7.4.250.0040.00416.57
7.4.240.0020.00616.56
7.4.230.0030.00316.39
7.4.220.0120.00616.65
7.4.210.0090.00716.67
7.4.200.0000.00716.68
7.4.190.0070.00016.80
7.4.160.0060.00916.41
7.4.150.0080.01217.40
7.4.140.0130.00617.86
7.4.130.0080.01116.54
7.4.120.0090.00916.68
7.4.110.0150.00316.50
7.4.100.0070.01016.45
7.4.90.0090.00916.64
7.4.80.0090.00919.39
7.4.70.0070.01016.71
7.4.60.0120.01116.41
7.4.50.0040.00416.17
7.4.40.0030.01222.77
7.4.30.0100.01316.71
7.4.00.0030.01415.04
7.3.330.0000.00513.41
7.3.320.0060.00013.27
7.3.310.0000.00716.32
7.3.300.0040.00416.29
7.3.290.0140.00716.35
7.3.280.0090.00816.42
7.3.270.0110.00817.40
7.3.260.0090.00916.40
7.3.250.0130.00816.60
7.3.240.0140.01016.43
7.3.230.0110.00716.52
7.3.210.0080.00816.55
7.3.200.0120.00919.39
7.3.190.0060.01616.53
7.3.180.0110.00616.52
7.3.170.0110.00616.40
7.3.160.0120.00616.57
7.3.120.0040.01114.89
7.2.330.0060.01216.95
7.2.320.0140.01016.82
7.2.310.0060.01216.63
7.2.300.0090.01516.52
7.2.290.0050.01016.61
7.2.60.0090.00616.97
7.1.200.0030.00515.91
7.1.70.0030.00616.95
7.1.60.0090.01619.82
7.1.50.0100.01316.99
7.1.00.0070.07322.45
7.0.200.0050.00316.69
7.0.140.0100.06722.16
7.0.110.0130.06719.98
7.0.100.0170.07319.95
7.0.90.0070.07020.01
7.0.80.0130.06319.99
7.0.70.0100.08019.96
7.0.60.0030.07720.01
7.0.50.0130.07320.24
7.0.40.0170.07020.27
7.0.30.0030.08720.16
7.0.20.0100.06320.03
7.0.10.0070.08020.02
7.0.00.0170.06020.20
5.6.280.0030.07021.19
5.6.250.0070.07320.63
5.6.240.0100.06720.51
5.6.230.0170.07020.60
5.6.220.0070.08020.73
5.6.210.0070.05720.55
5.6.200.0170.07021.15
5.6.190.0030.05320.99
5.6.180.0100.07320.97
5.6.170.0070.06021.13
5.6.160.0070.08321.27
5.6.150.0100.08321.12
5.6.140.0000.08020.97
5.6.130.0100.08321.12
5.6.120.0070.04321.11
5.6.110.0170.07321.18
5.6.100.0100.07721.09
5.6.90.0100.07021.16
5.6.80.0170.07020.48
5.6.70.0070.07720.47
5.6.60.0030.08320.68
5.6.50.0100.07720.71
5.6.40.0170.06320.55
5.6.30.0070.07720.55
5.6.20.0100.04720.41
5.6.10.0070.07720.53
5.6.00.0070.08020.43
5.5.380.0070.04020.60
5.5.370.0100.04020.38
5.5.360.0170.07320.38
5.5.350.0070.08320.56
5.5.340.0070.07320.95
5.5.330.0100.06721.05
5.5.320.0000.05320.94
5.5.310.0130.07720.94
5.5.300.0170.07021.01
5.5.290.0100.08321.02
5.5.280.0030.04320.85
5.5.270.0100.08020.84
5.5.260.0130.07320.77
5.5.250.0130.07320.82
5.5.240.0030.08320.22
5.5.230.0070.08020.40
5.5.220.0130.06720.15
5.5.210.0130.07020.45
5.5.200.0000.08320.30
5.5.190.0070.07720.38
5.5.180.0000.08320.23
5.5.160.0070.06720.20
5.5.150.0100.07020.38
5.5.140.0000.08320.35
5.5.130.0030.07720.23
5.5.120.0030.08320.16
5.5.110.0030.07020.28
5.5.100.0100.07320.20
5.5.90.0070.07020.01
5.5.80.0200.06720.24
5.5.70.0030.08020.29
5.5.60.0070.07320.17
5.5.50.0030.05320.26
5.5.40.0000.08020.03
5.5.30.0030.08020.17
5.5.20.0100.06320.16
5.5.10.0030.08020.09
5.5.00.0200.07020.22
5.4.450.0100.07719.36
5.4.440.0030.07319.32
5.4.430.0100.06319.34
5.4.420.0070.08019.32
5.4.410.0130.06319.23
5.4.400.0170.05719.19
5.4.390.0100.07019.01
5.4.380.0000.08718.98
5.4.370.0070.04718.99
5.4.360.0070.07719.21
5.4.350.0100.07019.02
5.4.340.0000.07719.34
5.4.320.0070.08019.16
5.4.310.0100.07319.03
5.4.300.0100.06718.95
5.4.290.0130.07019.16
5.4.280.0070.08018.98
5.4.270.0130.07019.00
5.4.260.0130.07019.00
5.4.250.0030.05019.22
5.4.240.0070.07319.00
5.4.230.0070.07318.95
5.4.220.0070.05318.98
5.4.210.0070.07318.95
5.4.200.0100.07018.98
5.4.190.0130.07018.98
5.4.180.0100.04018.97
5.4.170.0130.07019.15
5.4.160.0030.08018.97
5.4.150.0130.06319.18
5.4.140.0000.06016.61
5.4.130.0030.04716.58
5.4.120.0030.06016.64
5.4.110.0070.07716.63
5.4.100.0070.06316.37
5.4.90.0030.06716.48
5.4.80.0100.03016.46
5.4.70.0000.04016.35
5.4.60.0030.03716.47
5.4.50.0070.03716.52
5.4.40.0100.03016.50
5.4.30.0030.03716.45
5.4.20.0000.04016.57
5.4.10.0030.03716.49
5.4.00.0030.03315.96
5.3.290.0100.07314.66
5.3.280.0030.04714.70
5.3.270.0070.07314.63
5.3.260.0000.05014.64
5.3.250.0070.07314.61
5.3.240.0030.08014.69
5.3.230.0030.07714.58
5.3.220.0000.04314.53
5.3.210.0070.07714.42
5.3.200.0070.06714.43
5.3.190.0030.07714.56
5.3.180.0170.03314.69
5.3.170.0070.03314.65
5.3.160.0030.03714.71
5.3.150.0000.04014.71
5.3.140.0000.04014.57
5.3.130.0030.05314.41
5.3.120.0070.04014.53
5.3.110.0030.03714.56
5.3.100.0070.03714.13
5.3.90.0030.03314.16
5.3.80.0070.03314.09
5.3.70.0100.03014.25
5.3.60.0030.03314.14
5.3.50.0030.03713.81
5.3.40.0030.03313.97
5.3.30.0070.03713.89
5.3.20.0000.07013.69
5.3.10.0030.05313.66
5.3.00.0000.04013.71
5.2.170.0000.03011.05
5.2.160.0070.03311.05
5.2.150.0030.05011.05
5.2.140.0030.03011.08
5.2.130.0000.03311.00
5.2.120.0030.03311.03
5.2.110.0030.02711.04
5.2.100.0000.06311.26
5.2.90.0100.03010.99
5.2.80.0030.06311.11
5.2.70.0030.03311.11
5.2.60.0030.03311.13
5.2.50.0070.02710.96
5.2.40.0030.03011.15
5.2.30.0030.02710.91
5.2.20.0030.03010.89
5.2.10.0070.04310.75
5.2.00.0070.02310.71
5.1.60.0000.0239.98
5.1.50.0030.0239.90
5.1.40.0000.0279.90
5.1.30.0070.02010.18
5.1.20.0100.01710.26
5.1.10.0030.0409.99
5.1.00.0030.02310.06
5.0.50.0000.0308.70
5.0.40.0000.0238.35
5.0.30.0000.0378.24
5.0.20.0070.0138.02
5.0.10.0000.0208.32
5.0.00.0030.0478.18
4.4.90.0000.0177.89
4.4.80.0070.0107.89
4.4.70.0000.0177.89
4.4.60.0000.0177.89
4.4.50.0030.0377.89
4.4.40.0030.0207.89
4.4.30.0030.0177.89
4.4.20.0000.0137.89
4.4.10.0000.0277.89
4.4.00.0030.0537.89
4.3.110.0070.0207.89
4.3.100.0000.0177.89
4.3.90.0000.0137.89
4.3.80.0000.0277.89
4.3.70.0000.0137.89
4.3.60.0000.0337.89
4.3.50.0030.0307.89
4.3.40.0000.0377.89
4.3.30.0000.0277.89
4.3.20.0000.0177.89
4.3.10.0000.0177.89
4.3.00.0000.0137.89

preferences:
45.16 ms | 401 KiB | 5 Q