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 { 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)) { echo 111; print_r($exception->getVarList()); } }); } 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.00918.43
8.3.50.0070.00821.99
8.3.40.0060.01218.88
8.3.30.0170.00018.68
8.3.20.0030.00618.78
8.3.10.0080.00020.95
8.3.00.0000.00823.51
8.2.180.0070.01116.63
8.2.170.0140.00422.96
8.2.160.0060.01320.47
8.2.150.0110.00724.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0000.00820.86
8.2.110.0070.00322.11
8.2.100.0040.00817.84
8.2.90.0000.00819.21
8.2.80.0050.00317.97
8.2.70.0000.00817.63
8.2.60.0000.00918.04
8.2.50.0090.00018.07
8.2.40.0040.00418.09
8.2.30.0030.00621.22
8.2.20.0000.00817.85
8.2.10.0040.00417.86
8.2.00.0070.00017.67
8.1.280.0150.00025.92
8.1.270.0000.00823.99
8.1.260.0000.01726.35
8.1.250.0070.00728.09
8.1.240.0090.00019.19
8.1.230.0000.01120.83
8.1.220.0040.00418.77
8.1.210.0080.00018.89
8.1.200.0030.01017.35
8.1.190.0040.00417.53
8.1.180.0030.00618.10
8.1.170.0000.00818.64
8.1.160.0000.00718.86
8.1.150.0040.00418.52
8.1.140.0040.00417.31
8.1.130.0030.00517.86
8.1.120.0040.00417.34
8.1.110.0000.00717.44
8.1.100.0030.00417.51
8.1.90.0050.00217.47
8.1.80.0030.00517.46
8.1.70.0000.00717.42
8.1.60.0030.00617.53
8.1.50.0080.00017.54
8.1.40.0040.00417.51
8.1.30.0060.00317.62
8.1.20.0040.00417.54
8.1.10.0080.00017.52
8.1.00.0080.00317.46
8.0.300.0040.00420.02
8.0.290.0030.00317.29
8.0.280.0080.00018.50
8.0.270.0040.00417.31
8.0.260.0030.00316.93
8.0.250.0040.00417.10
8.0.240.0000.00817.06
8.0.230.0040.00417.10
8.0.220.0040.00316.99
8.0.210.0000.00716.88
8.0.200.0050.00216.98
8.0.190.0030.00617.08
8.0.180.0000.00717.08
8.0.170.0000.00817.05
8.0.160.0030.00316.96
8.0.150.0050.00316.96
8.0.140.0040.00416.92
8.0.130.0060.00013.42
8.0.120.0000.00816.99
8.0.110.0000.00916.95
8.0.100.0040.00416.80
8.0.90.0050.00316.88
8.0.80.0060.00916.89
8.0.70.0050.00216.92
8.0.60.0040.00416.83
8.0.50.0040.00416.85
8.0.30.0100.01217.26
8.0.20.0150.00517.40
8.0.10.0040.00416.84
8.0.00.0110.00816.78
7.4.330.0000.00516.77
7.4.320.0030.00316.59
7.4.300.0060.00016.58
7.4.290.0030.00316.64
7.4.280.0040.00416.54
7.4.270.0040.00716.63
7.4.260.0030.00313.22
7.4.250.0060.00316.63
7.4.240.0040.00416.66
7.4.230.0050.00216.48
7.4.220.0090.00916.58
7.4.210.0110.00616.60
7.4.200.0050.00216.68
7.4.190.0000.00716.51
7.4.160.0150.00616.46
7.4.150.0060.01317.40
7.4.140.0120.00417.86
7.4.130.0110.01116.54
7.4.120.0130.00516.52
7.4.110.0140.00316.83
7.4.100.0090.00916.50
7.4.90.0030.01516.46
7.4.80.0100.00719.39
7.4.70.0060.01516.62
7.4.60.0120.00616.69
7.4.50.0080.00016.16
7.4.40.0060.00922.77
7.4.30.0130.00716.46
7.4.10.0030.01316.70
7.4.00.0100.00515.82
7.3.330.0050.00013.50
7.3.320.0000.00613.48
7.3.310.0040.00416.56
7.3.300.0000.00716.49
7.3.290.0110.00816.41
7.3.280.0050.01016.44
7.3.270.0120.00617.40
7.3.260.0080.01018.24
7.3.250.0130.00816.49
7.3.240.0070.01816.49
7.3.230.0030.01316.59
7.3.210.0070.01316.56
7.3.200.0110.01119.39
7.3.190.0100.01316.64
7.3.180.0040.01316.55
7.3.170.0100.00716.50
7.3.160.0060.01516.50
7.3.130.0000.01216.62
7.3.120.0050.01215.77
7.3.110.0060.00916.45
7.3.100.0100.00716.48
7.3.90.0090.00616.32
7.3.80.0000.01216.60
7.3.70.0040.01216.52
7.3.60.0110.00416.40
7.3.50.0140.00416.54
7.3.40.0060.01016.45
7.3.30.0060.00916.50
7.3.20.0040.01118.25
7.3.10.0100.00717.45
7.3.00.0110.00917.24
7.2.330.0090.00916.81
7.2.320.0090.01516.78
7.2.310.0030.01416.50
7.2.300.0120.00916.90
7.2.290.0040.01416.75
7.2.260.0030.02016.51
7.2.250.0040.01816.86
7.2.240.0060.01316.72
7.2.230.0130.00316.76
7.2.220.0060.00916.54
7.2.210.0060.00916.67
7.2.200.0070.00716.73
7.2.190.0040.01216.53
7.2.180.0040.01116.66
7.2.170.0060.01016.76
7.2.160.0000.01916.73
7.2.150.0030.01318.43
7.2.140.0100.01018.28
7.2.130.0170.00517.69
7.2.120.0030.01217.62
7.2.110.0070.01317.44
7.2.100.0100.00817.59
7.2.90.0140.00417.56
7.2.80.0060.00717.51
7.2.70.0090.01017.74
7.2.60.0060.00817.37
7.2.50.0040.01417.67
7.2.40.0140.00317.68
7.2.30.0110.00617.70
7.2.20.0050.01117.43
7.2.10.0070.00717.63
7.2.00.0090.01018.21
7.1.330.0080.00817.48
7.1.320.0000.01417.47
7.1.310.0090.00617.25
7.1.300.0110.00317.30
7.1.290.0000.01017.46
7.1.280.0110.01117.28
7.1.270.0100.00717.31
7.1.260.0130.00617.34
7.1.250.0100.01016.30
7.1.240.0090.00317.23
7.1.230.0030.00717.31
7.1.220.0110.00417.34
7.1.210.0050.00917.30
7.1.200.0070.00616.67
7.1.190.0150.00017.20
7.1.180.0040.00717.53
7.1.170.0090.00617.30
7.1.160.0090.00617.45
7.1.150.0060.01217.43
7.1.140.0040.01117.38
7.1.130.0070.00717.24
7.1.120.0040.01117.32
7.1.110.0090.00617.47
7.1.100.0040.01117.47
7.1.90.0070.00717.49
7.1.80.0110.00417.20
7.1.70.0070.00617.24
7.1.60.0040.01117.28
7.1.50.0050.01117.23
7.1.40.0090.00417.16
7.1.30.0120.00417.29
7.1.20.0110.00717.14
7.1.10.0070.00717.11
7.1.00.0050.00717.14
7.0.330.0140.00016.90
7.0.320.0030.00616.91
7.0.310.0110.00317.00
7.0.300.0000.01117.04
7.0.290.0030.00916.98
7.0.280.0030.00616.98
7.0.270.0040.01117.00
7.0.260.0030.01017.06
7.0.250.0060.01017.03
7.0.240.0000.01416.93
7.0.230.0030.01316.97
7.0.220.0070.00716.93
7.0.210.0070.00717.04
7.0.200.0090.00416.98
7.0.190.0080.00817.01
7.0.180.0080.00617.10
7.0.170.0060.00917.00
7.0.160.0080.00817.04
7.0.150.0070.00616.98
7.0.140.0060.00316.93
7.0.130.0050.00916.92
7.0.120.0090.00517.02
7.0.110.0030.00916.94
7.0.100.0060.00417.03
7.0.90.0030.00916.98
7.0.80.0040.00716.99
7.0.70.0050.00517.08
7.0.60.0030.00816.97
7.0.50.0070.00517.01
7.0.40.0070.00715.98
7.0.30.0060.00516.01
7.0.20.0050.00715.96
7.0.10.0070.00415.96
7.0.00.0000.00915.97
5.6.400.0120.00616.02
5.6.390.0040.01215.98
5.6.380.0060.00615.79
5.6.370.0040.01115.80
5.6.360.0040.01116.32
5.6.350.0090.00316.45
5.6.340.0000.01615.86
5.6.330.0120.00416.30
5.6.320.0090.00616.09
5.6.310.0130.00316.13
5.6.300.0050.04118.41
5.6.290.0090.02218.26
5.6.280.0050.02518.50
5.6.270.0000.03018.67
5.6.260.0060.02218.45
5.6.250.0080.02218.44
5.6.240.0030.02818.50
5.6.230.0100.02518.50
5.6.220.0030.03018.55
5.6.210.0030.02418.25
5.6.200.0030.02918.48
5.6.190.0050.02818.34
5.6.180.0050.02418.51
5.6.170.0050.02618.55
5.6.160.0020.03418.51
5.6.150.0060.02918.49
5.6.140.0050.02918.27
5.6.130.0050.02518.42
5.6.120.0080.02118.22
5.6.110.0030.02818.34
5.6.100.0030.02418.45
5.6.90.0080.02418.54
5.6.80.0050.02618.18
5.6.70.0050.02518.21
5.6.60.0070.03318.07
5.6.50.0020.03018.09
5.6.40.0030.02618.26
5.6.30.0030.02518.09
5.6.20.0050.03118.16
5.6.10.0070.02418.18
5.6.00.0070.02218.07
5.5.380.0030.03016.70
5.5.370.0040.02616.79
5.5.360.0070.02616.78
5.5.350.0100.02116.73
5.5.340.0050.02717.02
5.5.330.0020.03016.97
5.5.320.0070.02317.06
5.5.310.0050.02917.04
5.5.300.0070.02217.01
5.5.290.0080.02417.05
5.5.280.0020.02916.88
5.5.270.0000.02716.99
5.5.260.0050.02517.13
5.5.250.0030.03016.96
5.5.240.0050.02716.71
5.5.230.0080.02216.77
5.5.220.0070.02216.66
5.5.210.0050.02316.55
5.5.200.0000.02716.67
5.5.190.0030.03016.67
5.5.180.0050.02416.52
5.5.170.0030.00915.97
5.5.160.0050.02716.71
5.5.150.0050.02516.71
5.5.140.0010.03816.65
5.5.130.0020.02916.57
5.5.120.0030.02516.59
5.5.110.0000.02916.79
5.5.100.0050.03916.59
5.5.90.0060.03916.57
5.5.80.0020.02816.68
5.5.70.0050.03116.60
5.5.60.0020.02816.61
5.5.50.0050.02316.54
5.5.40.0050.02616.60
5.5.30.0050.02416.58
5.5.20.0020.02916.57
5.5.10.0020.02616.60
5.5.00.0030.02516.61
5.4.450.0070.02315.90
5.4.440.0170.01916.11
5.4.430.0070.02416.02
5.4.420.0050.02616.02
5.4.410.0060.02315.97
5.4.400.0050.02215.84
5.4.390.0000.02515.77
5.4.380.0020.02415.92
5.4.370.0050.02015.94
5.4.360.0110.02215.95
5.4.350.0050.03916.01
5.4.340.0050.02915.90
5.4.330.0050.00512.66
5.4.320.0080.02415.93
5.4.310.0020.02815.88
5.4.300.0060.03415.86
5.4.290.0050.02416.07
5.4.280.0050.02715.76
5.4.270.0020.02515.87
5.4.260.0080.02915.98
5.4.250.0040.02315.91
5.4.240.0050.04115.88
5.4.230.0070.02815.91
5.4.220.0070.01815.94
5.4.210.0050.02115.77
5.4.200.0080.01915.96
5.4.190.0080.02115.86
5.4.180.0030.04615.86
5.4.170.0030.04115.85
5.4.160.0120.02215.81
5.4.150.0030.02615.87
5.4.140.0120.02314.88
5.4.130.0000.02614.86
5.4.120.0050.02114.90
5.4.110.0090.02414.85
5.4.100.0050.02214.85
5.4.90.0020.02414.86
5.4.80.0050.01914.86
5.4.70.0030.02114.87
5.4.60.0020.02814.81
5.4.50.0080.02414.89
5.4.40.0080.02114.90
5.4.30.0050.02114.86
5.4.20.0060.02214.81
5.4.10.0020.02914.82
5.4.00.0030.02414.85
5.3.290.0070.02314.88
5.3.280.0060.03914.76
5.3.270.0020.03314.94
5.3.260.0050.03014.88
5.3.250.0020.02914.88
5.3.240.0060.02414.82
5.3.230.0020.03014.85
5.3.220.0090.02114.89
5.3.210.0050.02214.91
5.3.200.0020.02414.81
5.3.190.0060.02414.87
5.3.180.0060.02314.92
5.3.170.0070.02614.85
5.3.160.0040.02314.92
5.3.150.0060.02314.92
5.3.140.0070.02314.88
5.3.130.0060.02414.89
5.3.120.0060.03114.88
5.3.110.0090.02414.89
5.3.100.0050.02514.88
5.3.90.0080.02214.87
5.3.80.0110.01914.86
5.3.70.0040.02614.90
5.3.60.0020.02914.96
5.3.50.0030.02214.84
5.3.40.0070.02214.79
5.3.30.0060.02414.87
5.3.20.0060.02314.82
5.3.10.0100.01814.72
5.3.00.0090.02114.78
5.2.170.0000.03516.97
5.2.160.0070.02716.97
5.2.150.0040.03016.97
5.2.140.0000.03116.97
5.2.130.0070.02716.97
5.2.120.0030.02716.97
5.2.110.0030.02816.97
5.2.100.0000.03216.97
5.2.90.0060.02616.97
5.2.80.0000.03316.97
5.2.70.0000.03616.97
5.2.60.0030.02916.97
5.2.50.0030.03116.97
5.2.40.0100.03116.97
5.2.30.0100.02416.97
5.2.20.0030.03016.97
5.2.10.0070.02616.97
5.2.00.0000.03816.97
5.1.60.0000.02716.97
5.1.50.0030.02416.97
5.1.40.0030.05416.97
5.1.30.0030.03416.97
5.1.20.0040.03316.97
5.1.10.0070.02116.97
5.1.00.0000.02816.97
5.0.50.0030.02616.97
5.0.40.0000.04016.97
5.0.30.0060.02716.97
5.0.20.0000.02116.97
5.0.10.0030.02016.97
5.0.00.0030.03216.97
4.4.90.0000.01816.97
4.4.80.0000.01816.97
4.4.70.0000.02116.97
4.4.60.0000.02116.97
4.4.50.0040.01916.97
4.4.40.0000.03016.97
4.4.30.0110.01116.97
4.4.20.0060.01216.97
4.4.10.0040.01416.97
4.4.00.0000.02616.97
4.3.110.0030.01916.97
4.3.100.0000.01716.97
4.3.90.0000.02016.97
4.3.80.0090.03716.97
4.3.70.0030.01416.97
4.3.60.0030.01316.97
4.3.50.0000.01716.97
4.3.40.0000.02616.97
4.3.30.0040.02516.97
4.3.20.0030.02116.97
4.3.10.0030.01516.97
4.3.00.0000.01716.97

preferences:
53.89 ms | 401 KiB | 5 Q