3v4l.org

run code in 300+ PHP versions simultaneously
<?php // 为避免污染全局命名空间,已对所有标识符加 `e` 前缀 /** * 运行模式 * * debug 调试模式, 会开启详细的日志记录和错误提示 * * default 默认模式, 会输出错误提示 * * production 生产模式, 不会执行任何额外操作, 最高效地执行代码 */ ob_start(); 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.0110.00717.00
8.3.50.0110.00818.31
8.3.40.0070.01118.74
8.3.30.0100.00718.72
8.3.20.0040.00418.70
8.3.10.0060.00320.64
8.3.00.0080.00019.38
8.2.180.0100.01316.75
8.2.170.0040.01522.96
8.2.160.0110.00619.00
8.2.150.0000.00824.18
8.2.140.0030.01324.66
8.2.130.0040.00426.16
8.2.120.0050.00518.83
8.2.110.0030.00620.38
8.2.100.0060.00618.03
8.2.90.0050.00519.37
8.2.80.0040.00419.41
8.2.70.0030.00617.74
8.2.60.0030.00517.93
8.2.50.0080.00418.07
8.2.40.0080.00018.28
8.2.30.0040.00418.10
8.2.20.0100.00017.62
8.2.10.0060.00317.79
8.2.00.0000.00817.84
8.1.280.0100.01025.92
8.1.270.0040.01423.99
8.1.260.0050.00326.35
8.1.250.0040.00428.09
8.1.240.0120.00020.84
8.1.230.0090.00321.09
8.1.220.0080.00017.78
8.1.210.0000.00818.95
8.1.200.0030.00617.38
8.1.190.0040.00417.43
8.1.180.0040.00418.10
8.1.170.0060.00319.08
8.1.160.0000.00818.94
8.1.150.0030.00518.66
8.1.140.0040.00417.63
8.1.130.0000.00717.95
8.1.120.0080.00017.49
8.1.110.0050.00217.51
8.1.100.0050.00217.40
8.1.90.0000.00817.50
8.1.80.0040.00417.53
8.1.70.0000.00717.42
8.1.60.0040.00417.54
8.1.50.0040.00417.59
8.1.40.0050.00317.60
8.1.30.0000.00817.71
8.1.20.0040.00417.63
8.1.10.0000.00817.55
8.1.00.0050.00317.53
8.0.300.0000.00720.15
8.0.290.0000.00816.75
8.0.280.0000.00818.50
8.0.270.0000.00817.33
8.0.260.0000.00716.85
8.0.250.0040.00417.11
8.0.240.0030.00317.08
8.0.230.0030.00317.04
8.0.220.0000.00716.99
8.0.210.0000.00717.06
8.0.200.0030.00317.12
8.0.190.0040.00417.04
8.0.180.0040.00417.00
8.0.170.0030.00616.92
8.0.160.0040.00417.05
8.0.150.0030.00616.99
8.0.140.0000.00816.87
8.0.130.0030.00313.46
8.0.120.0030.00516.95
8.0.110.0000.00716.97
8.0.100.0040.00416.86
8.0.90.0040.00416.81
8.0.80.0120.00616.91
8.0.70.0000.00716.86
8.0.60.0040.00416.90
8.0.50.0040.00416.83
8.0.30.0170.00017.13
8.0.20.0100.01317.40
8.0.10.0070.00017.09
8.0.00.0150.00616.87
7.4.330.0000.00513.17
7.4.320.0030.00316.65
7.4.300.0000.00716.58
7.4.290.0050.00316.66
7.4.280.0040.00416.55
7.4.270.0030.00316.63
7.4.260.0030.00313.38
7.4.250.0020.00516.73
7.4.240.0040.00416.64
7.4.230.0080.00016.67
7.4.220.0150.00316.66
7.4.210.0050.01016.63
7.4.200.0050.00316.67
7.4.190.0040.00416.38
7.4.160.0100.00716.48
7.4.150.0070.01016.55
7.4.140.0090.01516.49
7.4.130.0110.00716.61
7.4.120.0100.00716.55
7.4.110.0090.00816.60
7.4.100.0000.01716.50
7.4.90.0060.01616.65
7.4.80.0120.00619.39
7.4.70.0090.01216.46
7.4.60.0090.01216.50
7.4.50.0030.00516.59
7.4.40.0060.01016.61
7.4.30.0130.00916.69
7.4.10.0040.01816.59
7.4.00.0110.00615.88
7.3.330.0000.00613.32
7.3.320.0000.00813.33
7.3.310.0030.00516.47
7.3.300.0030.00316.35
7.3.290.0090.00616.52
7.3.280.0060.01216.43
7.3.270.0140.01016.62
7.3.260.0030.02016.79
7.3.250.0080.01416.50
7.3.240.0060.01116.45
7.3.230.0070.01116.48
7.3.210.0100.01416.54
7.3.200.0090.00816.57
7.3.190.0060.01616.51
7.3.180.0060.00916.59
7.3.170.0100.00716.46
7.3.160.0170.00716.73
7.3.130.0160.00616.57
7.3.120.0050.01115.76
7.3.110.0090.00916.61
7.3.100.0030.01216.38
7.3.90.0000.01916.35
7.3.80.0000.00916.71
7.3.70.0070.00316.45
7.3.60.0140.00016.58
7.3.50.0100.00016.38
7.3.40.0000.01216.36
7.3.30.0060.01016.43
7.3.20.0070.00418.14
7.3.10.0100.00717.47
7.3.00.0070.00717.36
7.2.330.0030.01416.65
7.2.320.0070.01116.84
7.2.310.0090.00916.89
7.2.300.0200.00316.80
7.2.290.0100.01016.59
7.2.260.0040.01816.54
7.2.250.0120.00916.72
7.2.240.0030.01016.67
7.2.230.0030.01016.40
7.2.220.0000.01516.57
7.2.210.0030.01016.64
7.2.200.0080.00816.65
7.2.190.0030.01316.54
7.2.180.0060.00916.50
7.2.170.0110.00416.56
7.2.160.0110.00716.39
7.2.150.0000.01318.51
7.2.140.0030.00718.45
7.2.130.0070.00517.57
7.2.120.0030.01017.50
7.2.110.0110.00517.78
7.2.100.0070.00517.72
7.2.90.0050.00817.54
7.2.80.0030.00917.73
7.2.70.0020.01317.58
7.2.60.0060.01017.49
7.2.50.0060.01017.73
7.2.40.0100.00417.62
7.2.30.0100.00517.62
7.2.20.0120.00617.68
7.2.10.0100.00217.55
7.2.00.0020.00918.09
7.1.330.0030.01017.22
7.1.320.0040.00817.44
7.1.310.0070.00717.43
7.1.300.0100.00317.14
7.1.290.0040.00817.32
7.1.280.0030.00717.25
7.1.270.0070.00717.63
7.1.260.0000.00917.33
7.1.250.0080.01116.51
7.1.240.0000.01017.38
7.1.230.0060.00617.43
7.1.220.0060.00617.15
7.1.210.0070.00717.30
7.1.200.0090.00816.51
7.1.190.0030.01217.28
7.1.180.0100.00717.36
7.1.170.0060.00917.27
7.1.160.0130.00017.21
7.1.150.0040.01117.43
7.1.140.0040.00817.40
7.1.130.0040.01217.47
7.1.120.0040.00717.59
7.1.110.0000.01317.33
7.1.100.0070.00917.58
7.1.90.0030.00617.53
7.1.80.0030.01017.41
7.1.70.0040.00817.22
7.1.60.0070.01218.35
7.1.50.0190.01126.13
7.1.40.0060.00317.51
7.1.30.0040.01517.29
7.1.20.0100.00717.37
7.1.10.0000.01117.25
7.1.00.0040.02119.88
7.0.330.0030.00616.96
7.0.320.0030.00616.94
7.0.310.0060.00316.88
7.0.300.0040.01116.89
7.0.290.0100.00316.96
7.0.280.0030.01316.98
7.0.270.0030.01017.01
7.0.260.0030.01017.14
7.0.250.0080.00317.11
7.0.240.0080.00817.07
7.0.230.0070.00716.94
7.0.220.0040.00417.10
7.0.210.0100.00317.09
7.0.200.0080.00416.90
7.0.190.0030.01317.13
7.0.180.0030.01017.05
7.0.170.0040.01217.14
7.0.160.0070.00417.04
7.0.150.0040.01116.94
7.0.140.0050.03819.55
7.0.130.0060.00917.01
7.0.120.0100.03119.50
7.0.110.0030.01316.99
7.0.100.0070.00717.00
7.0.90.0070.00816.97
7.0.80.0070.00317.15
7.0.70.0040.00817.14
7.0.60.0080.04918.52
7.0.50.0090.02217.60
7.0.40.0070.02217.59
7.0.30.0120.03017.59
7.0.20.0200.04317.61
7.0.10.0080.03817.53
7.0.00.0050.04717.64
5.6.400.0060.00616.19
5.6.390.0060.00916.15
5.6.380.0070.00716.15
5.6.370.0050.00816.02
5.6.360.0110.00416.14
5.6.350.0060.00616.17
5.6.340.0080.00416.16
5.6.330.0100.00616.02
5.6.320.0060.00616.32
5.6.310.0110.00715.79
5.6.300.0000.00916.30
5.6.290.0110.00416.04
5.6.280.0070.03918.38
5.6.270.0040.00816.12
5.6.260.0090.00615.95
5.6.250.0090.00915.95
5.6.240.0040.01115.95
5.6.230.0070.00415.92
5.6.220.0090.00615.93
5.6.210.0110.03718.22
5.6.200.0070.02317.13
5.6.190.0110.04518.52
5.6.180.2050.02418.31
5.6.170.0080.02918.29
5.6.160.0110.03318.21
5.6.150.0030.02417.05
5.6.140.0030.04917.19
5.6.130.0070.03716.97
5.6.120.0050.02218.62
5.6.110.0050.04718.46
5.6.100.0070.03518.71
5.6.90.0050.02418.45
5.6.80.0100.03218.09
5.6.70.2200.02518.15
5.6.60.0090.00915.82
5.6.50.0040.00715.86
5.6.40.0070.00715.94
5.6.30.0030.01416.14
5.6.20.0060.00915.82
5.6.10.0070.01116.21
5.6.00.0080.00816.14
5.5.380.0040.01116.01
5.5.370.0000.01315.95
5.5.360.0030.01516.09
5.5.350.0040.02418.18
5.5.340.0030.02916.88
5.5.330.0070.05118.10
5.5.320.0150.04217.97
5.5.310.0130.02818.04
5.5.300.0030.04516.86
5.5.290.0070.02316.97
5.5.280.0070.04018.35
5.5.270.0030.04918.31
5.5.260.0070.04018.24
5.5.250.0150.03818.27
5.5.240.0120.04417.89
5.5.230.0030.01415.70
5.5.220.0090.00915.69
5.5.210.0060.01015.60
5.5.200.0090.00615.90
5.5.190.0060.01015.70
5.5.180.0030.01215.63
5.5.170.0130.00615.68
5.5.160.0150.00315.95
5.5.150.0090.00615.86
5.5.140.0060.00615.81
5.5.130.0070.01015.77
5.5.120.0110.00415.72
5.5.110.0000.01415.90
5.5.100.0060.00615.90
5.5.90.0100.00315.59
5.5.80.0030.00615.72
5.5.70.0110.00415.97
5.5.60.0060.00315.80
5.5.50.0100.00615.84
5.5.40.0070.00615.86
5.5.30.0030.00715.95
5.5.20.0070.00415.70
5.5.10.0030.01215.68
5.5.00.0030.01515.81
5.4.450.0060.03816.16
5.4.440.0030.02516.08
5.4.430.0030.02516.10
5.4.420.0030.02316.06
5.4.410.0040.02316.03
5.4.400.0020.02315.94
5.4.390.0050.02415.89
5.4.380.0050.02015.86
5.4.370.0050.02215.90
5.4.360.0060.02315.94
5.4.350.0050.02315.76
5.4.340.0030.02315.85
5.4.330.0090.00612.65
5.4.320.0040.02115.92
5.4.310.0090.01915.79
5.4.300.0070.02215.94
5.4.290.0060.02515.78
5.4.280.0060.02115.97
5.4.270.0050.02515.75
5.4.260.0050.02215.94
5.4.250.0050.01815.80
5.4.240.0050.02115.94
5.4.230.0030.02515.83
5.4.220.0030.02515.76
5.4.210.0080.04115.89
5.4.200.0040.04615.75
5.4.190.0070.03915.90
5.4.180.0050.02715.94
5.4.170.0040.02615.74
5.4.160.0060.03515.76
5.4.150.0040.02315.94
5.4.140.0120.03714.54
5.4.130.0070.03314.55
5.4.120.0050.04014.60
5.4.110.0000.03914.60
5.4.100.0000.04914.62
5.4.90.0050.03914.59
5.4.80.0080.03514.58
5.4.70.0050.02714.49
5.4.60.0050.03014.47
5.4.50.0060.03814.56
5.4.40.0160.03014.64
5.4.30.0080.03714.47
5.4.20.0080.02614.53
5.4.10.0020.04514.55
5.4.00.0050.03214.32
5.3.290.0050.02213.74
5.3.280.0030.02713.63
5.3.270.0140.03313.71
5.3.260.0040.02413.60
5.3.250.0030.04813.69
5.3.240.0050.03713.57
5.3.230.0070.02913.66
5.3.220.0050.03513.64
5.3.210.0090.02313.70
5.3.200.0120.03713.61
5.3.190.0080.04013.66
5.3.180.0090.03813.66
5.3.170.0060.02713.71
5.3.160.0100.03413.66
5.3.150.0060.04313.80
5.3.140.0110.02513.73
5.3.130.0070.04513.81
5.3.120.0070.04713.68
5.3.110.0090.04613.68
5.3.100.0110.03913.55
5.3.90.0070.03113.51
5.3.80.0090.04013.38
5.3.70.0120.03813.44
5.3.60.0120.03713.41
5.3.50.0100.03813.34
5.3.40.0050.03813.28
5.3.30.0100.02213.34
5.3.20.0070.04213.25
5.3.10.0060.04413.17
5.3.00.0080.04013.16
5.2.170.0000.06311.17
5.2.160.0070.07011.30
5.2.150.0070.03311.14
5.2.140.0030.04011.04
5.2.130.0030.04710.93
5.2.120.0000.06311.26
5.2.110.0170.04711.03
5.2.100.0100.06010.99
5.2.90.0030.05711.19
5.2.80.0000.06311.04
5.2.70.0030.05010.99
5.2.60.0100.05010.90
5.2.50.0070.06310.87
5.2.40.0070.05310.89
5.2.30.0100.05710.85
5.2.20.0030.06010.95
5.2.10.0030.03310.86
5.2.00.0070.05710.87
5.1.60.0070.03310.04
5.1.50.0000.03310.04
5.1.40.0030.05710.13
5.1.30.0030.04310.32
5.1.20.0030.05310.20
5.1.10.0070.03710.04
5.1.00.0070.0439.97
5.0.50.0070.0408.55
5.0.40.0000.0378.49
5.0.30.0100.0608.27
5.0.20.0030.0338.19
5.0.10.0030.0438.18
5.0.00.0030.0538.15
4.4.90.0000.0177.91
4.4.80.0030.0337.91
4.4.70.0070.0207.91
4.4.60.0000.0377.91
4.4.50.0000.0207.91
4.4.40.0000.0307.91
4.4.30.0100.0177.91
4.4.20.0070.0337.91
4.4.10.0000.0277.91
4.4.00.0000.0507.91
4.3.110.0030.0407.91
4.3.100.0030.0237.91
4.3.90.0030.0337.91
4.3.80.0030.0307.91
4.3.70.0000.0177.91
4.3.60.0000.0307.91
4.3.50.0070.0337.91
4.3.40.0000.0607.91
4.3.30.0000.0237.91
4.3.20.0030.0277.91
4.3.10.0030.0307.91
4.3.00.0030.0237.91

preferences:
48.69 ms | 401 KiB | 5 Q