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); }); register_shutdown_function(function() { $error = error_get_last(); if($error['type'] === E_ERROR) throw new ePHPException($error['message'], 0, $error['type'], $error['file'], $error['line']); }); 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 "+++"; set_exception_handler(function(Exception $exception) { echo "---"; // 暂时我们只打算以纯文本的形式展示信息 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()); }); } array_keys(1);

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.00316.88
8.3.50.0110.00522.05
8.3.40.0080.00818.82
8.3.30.0000.01518.90
8.3.20.0040.00418.75
8.3.10.0040.00420.71
8.3.00.0050.00321.85
8.2.180.0070.00716.88
8.2.170.0090.00622.96
8.2.160.0140.00020.27
8.2.150.0040.00424.18
8.2.140.0030.00624.66
8.2.130.0040.00426.16
8.2.120.0050.00319.36
8.2.110.0070.00322.16
8.2.100.0030.00917.80
8.2.90.0000.00919.36
8.2.80.0080.00017.97
8.2.70.0050.00317.75
8.2.60.0000.00817.93
8.2.50.0040.00418.07
8.2.40.0000.00818.34
8.2.30.0000.00919.91
8.2.20.0000.00817.80
8.2.10.0080.00017.75
8.2.00.0040.00417.74
8.1.280.0120.00625.92
8.1.270.0040.00423.99
8.1.260.0030.00626.35
8.1.250.0080.00028.09
8.1.240.0030.00622.05
8.1.230.0110.00017.42
8.1.220.0000.00817.79
8.1.210.0030.00518.77
8.1.200.0060.00317.47
8.1.190.0040.00417.66
8.1.180.0080.00018.10
8.1.170.0040.00418.82
8.1.160.0000.00718.91
8.1.150.0000.00818.80
8.1.140.0040.00417.42
8.1.130.0040.00417.88
8.1.120.0040.00417.55
8.1.110.0060.00317.58
8.1.100.0050.00317.41
8.1.90.0040.00417.45
8.1.80.0000.00817.53
8.1.70.0040.00417.47
8.1.60.0000.00917.53
8.1.50.0000.00917.46
8.1.40.0090.00017.48
8.1.30.0090.00017.73
8.1.20.0030.00517.73
8.1.10.0000.00817.63
8.1.00.0070.00317.60
8.0.300.0070.00018.77
8.0.290.0000.00816.88
8.0.280.0000.00818.40
8.0.270.0000.00717.17
8.0.260.0070.00016.95
8.0.250.0000.00817.02
8.0.240.0000.00817.06
8.0.230.0000.00716.97
8.0.220.0040.00417.05
8.0.210.0000.00716.94
8.0.200.0000.00717.06
8.0.190.0040.00417.06
8.0.180.0080.00017.06
8.0.170.0040.00416.91
8.0.160.0040.00416.98
8.0.150.0050.00516.99
8.0.140.0030.00616.84
8.0.130.0000.00613.37
8.0.120.0040.00416.92
8.0.110.0030.00517.04
8.0.100.0040.00416.91
8.0.90.0000.00816.90
8.0.80.0130.00616.98
8.0.70.0040.00417.01
8.0.60.0050.00317.08
8.0.50.0040.00416.95
8.0.30.0120.00717.05
8.0.20.0100.01017.40
8.0.10.0000.00717.03
8.0.00.0070.01116.85
7.4.330.0060.00014.65
7.4.320.0000.00616.49
7.4.300.0000.00716.57
7.4.290.0000.00716.50
7.4.280.0040.00416.58
7.4.270.0070.00016.67
7.4.260.0000.00613.28
7.4.250.0070.00016.57
7.4.240.0070.00016.46
7.4.230.0000.00716.54
7.4.220.0130.00316.61
7.4.210.0070.00916.62
7.4.200.0030.00516.75
7.4.190.0030.00316.74
7.4.160.0120.00816.40
7.4.150.0070.01017.40
7.4.140.0120.00817.86
7.4.130.0060.01116.63
7.4.120.0120.01016.73
7.4.110.0130.00316.70
7.4.100.0060.01516.62
7.4.90.0090.00916.48
7.4.80.0060.01219.04
7.4.70.0090.00916.57
7.4.60.0130.00316.54
7.4.50.0030.00616.61
7.4.40.0060.00922.27
7.4.30.0090.01216.56
7.4.00.0060.01115.08
7.3.330.0000.00513.47
7.3.320.0030.00313.42
7.3.310.0000.00716.33
7.3.300.0070.00016.35
7.3.290.0040.01116.47
7.3.280.0070.01216.46
7.3.270.0140.01117.40
7.3.260.0090.00818.24
7.3.250.0110.00716.69
7.3.240.0050.01316.39
7.3.230.0080.01116.48
7.3.210.0070.01116.52
7.3.200.0090.00919.39
7.3.190.0080.01216.52
7.3.180.0100.00716.70
7.3.170.0110.01116.73
7.3.160.0120.00616.46
7.3.120.0050.01114.82
7.3.110.0100.01014.95
7.3.100.0000.01514.61
7.3.90.0040.00814.89
7.3.80.0100.00314.96
7.3.70.0070.00714.71
7.3.60.0060.00614.89
7.3.50.0040.01514.91
7.3.40.0000.01414.84
7.3.30.0030.01214.92
7.3.20.0060.01316.88
7.3.10.0090.00616.77
7.3.00.0030.01416.64
7.2.330.0070.01016.71
7.2.320.0220.00316.92
7.2.310.0120.00916.51
7.2.300.0080.00816.70
7.2.290.0130.01016.77
7.2.250.0070.01115.09
7.2.240.0070.01015.13
7.2.230.0030.01315.14
7.2.220.0040.01115.09
7.2.210.0090.00915.03
7.2.200.0030.00815.08
7.2.190.0030.01615.18
7.2.180.0040.01415.35
7.2.170.0070.01014.95
7.2.60.0100.00616.81
7.2.00.0030.01019.30
7.1.330.0000.01515.84
7.1.320.0070.00715.84
7.1.310.0030.00915.85
7.1.300.0000.01215.66
7.1.290.0040.01115.83
7.1.280.0030.01215.81
7.1.270.0090.00915.92
7.1.260.0070.00715.93
7.1.200.0070.00715.60
7.1.100.0080.00818.24
7.1.70.0030.00717.04
7.1.60.0070.01719.40
7.1.50.0100.01316.99
7.1.00.0030.06322.45
7.0.200.0040.00416.80
7.0.140.0100.06722.09
7.0.60.0170.06319.94
7.0.50.0100.06317.94
7.0.40.0070.07017.85
7.0.30.0170.06717.69
7.0.20.0070.08317.85
7.0.10.0170.07317.75
7.0.00.0070.08317.75
5.6.280.0000.07720.93
5.6.210.0070.07720.51
5.6.200.0100.08018.15
5.6.190.0070.08318.18
5.6.180.0000.04718.26
5.6.170.0130.07018.19
5.6.160.0100.07318.15
5.6.150.0130.07318.17
5.6.140.0100.04318.24
5.6.130.0100.08318.27
5.6.120.0100.03718.29
5.6.110.0070.05718.33
5.6.100.0000.05318.16
5.6.90.0070.08718.18
5.6.80.0000.04317.67
5.6.70.0030.04017.54
5.6.60.0070.03317.64
5.6.50.0000.04017.65
5.6.40.0030.04017.53
5.6.30.0070.04317.65
5.6.20.0070.04317.55
5.6.10.0030.06717.64
5.6.00.0030.03717.52
5.5.350.0030.07720.46
5.5.340.0200.05018.05
5.5.330.0130.07317.99
5.5.320.0030.04017.94
5.5.310.0070.08017.98
5.5.300.0070.04018.04
5.5.290.0130.07718.00
5.5.280.0030.04018.07
5.5.270.0130.07717.94
5.5.260.0100.08018.04
5.5.250.0070.05017.79
5.5.240.0000.04017.35
5.5.230.0070.03317.46
5.5.220.0070.03317.38
5.5.210.0030.04317.33
5.5.200.0030.03717.31
5.5.190.0070.03317.34
5.5.180.0030.07017.36
5.5.160.0200.03017.34
5.5.150.0000.04017.30
5.5.140.0100.03717.43
5.5.130.0000.04317.38
5.5.120.0070.04017.38
5.5.110.0000.04017.42
5.5.100.0000.04017.25
5.5.90.0070.03317.32
5.5.80.0030.03717.23
5.5.70.0070.03317.21
5.5.60.0030.03717.25
5.5.50.0070.04017.22
5.5.40.0030.03717.23
5.5.30.0130.02717.27
5.5.20.0070.03317.22
5.5.10.0030.04017.21
5.5.00.0030.04017.24
5.4.450.0100.07719.42
5.4.440.0070.05719.36
5.4.430.0100.07019.46
5.4.420.0070.06019.27
5.4.410.0100.07019.24
5.4.400.0000.04019.02
5.4.390.0000.04019.14
5.4.380.0000.04319.11
5.4.370.0100.03019.27
5.4.360.0070.03319.03
5.4.350.0030.08019.04
5.4.340.0030.04319.04
5.4.320.0070.04019.10
5.4.310.0030.03719.06
5.4.300.0070.03719.12
5.4.290.0030.06719.04
5.4.280.0030.03719.03
5.4.270.0000.04319.02
5.4.260.0070.03319.01
5.4.250.0130.03319.13
5.4.240.0030.03719.09
5.4.230.0030.03719.00
5.4.220.0100.03318.88
5.4.210.0100.03019.01
5.4.200.0070.03319.30
5.4.190.0100.03019.12
5.4.180.0070.03319.02
5.4.170.0000.04019.11
5.4.160.0030.03719.03
5.4.150.0070.03719.01
5.4.140.0000.03716.34
5.4.130.0000.04316.35
5.4.120.0000.04016.57
5.4.110.0030.03716.40
5.4.100.0000.08016.50
5.4.90.0070.04316.39
5.4.80.0070.07016.41
5.4.70.0100.07316.52
5.4.60.0130.06716.60
5.4.50.0070.03716.41
5.4.40.0070.07716.48
5.4.30.0130.07016.47
5.4.20.0030.07316.43
5.4.10.0070.03716.25
5.4.00.0100.06715.91
5.3.290.0030.04014.72
5.3.280.0070.03314.70
5.3.270.0000.04014.62
5.3.260.0070.03314.65
5.3.250.0000.03714.59
5.3.240.0030.03314.68
5.3.230.0170.03714.65
5.3.220.0070.07314.58
5.3.210.0030.07014.67
5.3.200.0030.03714.59
5.3.190.0070.07014.63
5.3.180.0070.07314.59
5.3.170.0130.07014.38
5.3.160.0200.06314.41
5.3.150.0030.05714.64
5.3.140.0030.08014.52
5.3.130.0000.08014.62
5.3.120.0030.04714.66
5.3.110.0100.04314.54
5.3.100.0000.07014.08
5.3.90.0130.05714.05
5.3.80.0100.06014.03
5.3.70.0000.08314.04
5.3.60.0100.06314.04
5.3.50.0030.06713.96
5.3.40.0000.04314.05
5.3.30.0100.07013.91
5.3.20.0070.06713.91
5.3.10.0100.07013.52
5.3.00.0170.06313.48
5.2.170.0000.07010.96
5.2.160.0030.04711.12
5.2.150.0070.05711.29
5.2.140.0070.05010.97
5.2.130.0070.06711.08
5.2.120.0070.06011.10
5.2.110.0030.06011.07
5.2.100.0070.06011.24
5.2.90.0030.04011.00
5.2.80.0130.05311.04
5.2.70.0170.04310.92
5.2.60.0100.05311.02
5.2.50.0030.06010.94
5.2.40.0030.06010.94
5.2.30.0100.06010.91
5.2.20.0030.06010.91
5.2.10.0030.06010.90
5.2.00.0070.03710.70
5.1.60.0030.0279.90
5.1.50.0100.05010.07
5.1.40.0000.0579.91
5.1.30.0100.04010.39
5.1.20.0030.06010.32
5.1.10.0070.05010.11
5.1.00.0000.04310.09
5.0.50.0000.0508.52
5.0.40.0070.0238.41
5.0.30.0100.0578.20
5.0.20.0030.0408.16
5.0.10.0030.0408.10
5.0.00.0030.0538.36
4.4.90.0100.0177.63
4.4.80.0000.0277.63
4.4.70.0070.0277.63
4.4.60.0000.0407.63
4.4.50.0030.0337.63
4.4.40.0070.0437.63
4.4.30.0100.0307.63
4.4.20.0000.0307.63
4.4.10.0070.0307.63
4.4.00.0000.0577.63
4.3.110.0030.0337.63
4.3.100.0030.0377.63
4.3.90.0030.0307.63
4.3.80.0030.0537.63
4.3.70.0030.0207.63
4.3.60.0100.0307.63
4.3.50.0000.0337.63
4.3.40.0030.0537.63
4.3.30.0000.0407.63
4.3.20.0030.0277.63
4.3.10.0000.0377.63
4.3.00.0030.0307.63

preferences:
48.91 ms | 401 KiB | 5 Q