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(1) { 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.0080.00818.68
8.3.50.0070.00921.92
8.3.40.0140.00718.84
8.3.30.0110.00418.76
8.3.20.0030.00518.76
8.3.10.0040.00420.96
8.3.00.0040.00421.90
8.2.180.0130.00616.48
8.2.170.0090.00622.96
8.2.160.0070.01320.57
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0050.00220.94
8.2.110.0060.00320.94
8.2.100.0110.00017.72
8.2.90.0030.00619.26
8.2.80.0000.00817.97
8.2.70.0050.00317.63
8.2.60.0050.00317.80
8.2.50.0050.00418.07
8.2.40.0050.00318.16
8.2.30.0060.00321.28
8.2.20.0000.00817.77
8.2.10.0030.00517.78
8.2.00.0040.00417.70
8.1.280.0110.00725.92
8.1.270.0080.00023.99
8.1.260.0090.00026.35
8.1.250.0080.00028.09
8.1.240.0050.00521.27
8.1.230.0060.00620.98
8.1.220.0030.00618.77
8.1.210.0050.00318.82
8.1.200.0040.00417.22
8.1.190.0000.00817.53
8.1.180.0040.00418.10
8.1.170.0030.00618.57
8.1.160.0000.00918.79
8.1.150.0050.00218.62
8.1.140.0000.00717.48
8.1.130.0000.00717.66
8.1.120.0040.00417.38
8.1.110.0050.00317.33
8.1.100.0020.00517.51
8.1.90.0040.00417.44
8.1.80.0040.00417.40
8.1.70.0000.00817.43
8.1.60.0000.00817.46
8.1.50.0060.00317.36
8.1.40.0080.00017.41
8.1.30.0050.00317.63
8.1.20.0030.00617.50
8.1.10.0080.00017.51
8.1.00.0070.00417.48
8.0.300.0040.00420.16
8.0.290.0000.01017.30
8.0.280.0040.00418.49
8.0.270.0000.00717.29
8.0.260.0030.00316.84
8.0.250.0000.00817.02
8.0.240.0030.00617.03
8.0.230.0040.00417.12
8.0.220.0070.00017.05
8.0.210.0050.00316.89
8.0.200.0070.00017.00
8.0.190.0040.00417.03
8.0.180.0030.00517.05
8.0.170.0060.00317.01
8.0.160.0040.00416.93
8.0.150.0000.00816.98
8.0.140.0000.00816.93
8.0.130.0030.00313.39
8.0.120.0070.00016.82
8.0.110.0080.00016.80
8.0.100.0040.00417.04
8.0.90.0000.00716.98
8.0.80.0150.00017.00
8.0.70.0040.00416.90
8.0.60.0040.00416.92
8.0.50.0080.00016.89
8.0.30.0090.01017.12
8.0.20.0150.00517.40
8.0.10.0040.00417.13
8.0.00.0140.01116.79
7.4.330.0050.00016.88
7.4.320.0000.00616.65
7.4.300.0000.00616.66
7.4.290.0000.00716.71
7.4.280.0070.00016.45
7.4.270.0070.00016.68
7.4.260.0030.00313.36
7.4.250.0040.00416.62
7.4.240.0040.00416.63
7.4.230.0070.00016.69
7.4.220.0100.01416.52
7.4.210.0060.01116.67
7.4.200.0030.00516.72
7.4.190.0000.00716.74
7.4.160.0110.01116.82
7.4.150.0090.01317.40
7.4.140.0080.00917.86
7.4.130.0140.00416.63
7.4.120.0100.00816.58
7.4.110.0100.00716.57
7.4.100.0130.00616.70
7.4.90.0120.00616.57
7.4.80.0150.00919.39
7.4.70.0150.00616.37
7.4.60.0110.00616.63
7.4.50.0030.00616.53
7.4.40.0090.00622.77
7.4.30.0060.00916.67
7.4.10.0030.01515.09
7.4.00.0110.00815.03
7.3.330.0030.00313.46
7.3.320.0000.00513.29
7.3.310.0030.00316.52
7.3.300.0020.00516.35
7.3.290.0100.01016.43
7.3.280.0070.01116.42
7.3.270.0030.01417.40
7.3.260.0090.01318.24
7.3.250.0100.01216.43
7.3.240.0070.01016.34
7.3.230.0150.00816.58
7.3.210.0140.00516.63
7.3.200.0100.00819.39
7.3.190.0200.00316.56
7.3.180.0110.00516.50
7.3.170.0060.00916.62
7.3.160.0090.00716.61
7.3.130.0030.01315.23
7.3.120.0120.00514.89
7.3.110.0130.00314.92
7.3.100.0000.01314.77
7.3.90.0040.01114.92
7.3.80.0110.00414.89
7.3.70.0070.01014.83
7.3.60.0000.01715.02
7.3.50.0110.00014.72
7.3.40.0090.00614.97
7.3.30.0040.01115.00
7.3.20.0030.00616.86
7.3.10.0090.00616.88
7.3.00.0100.00716.54
7.2.330.0060.01216.89
7.2.320.0090.00916.50
7.2.310.0070.01716.78
7.2.300.0070.01016.75
7.2.290.0130.00416.73
7.2.260.0030.01615.21
7.2.250.0060.01215.37
7.2.240.0090.00615.05
7.2.230.0060.00615.16
7.2.220.0040.01514.97
7.2.210.0070.00714.95
7.2.200.0040.01115.23
7.2.190.0080.00415.04
7.2.180.0060.00915.10
7.2.170.0030.01015.29
7.2.160.0030.01015.18
7.2.150.0040.01416.84
7.2.140.0030.00616.85
7.2.130.0080.00816.66
7.2.120.0130.00317.05
7.2.110.0070.01016.99
7.2.100.0040.01116.96
7.2.90.0070.00716.71
7.2.80.0030.01516.84
7.2.70.0030.00617.02
7.2.60.0030.01016.87
7.2.50.0050.00517.15
7.2.40.0110.00617.12
7.2.30.0030.00617.02
7.2.20.0030.01016.93
7.2.10.0130.00316.89
7.2.00.0080.00618.03
7.1.330.0100.00315.86
7.1.320.0100.00715.97
7.1.310.0090.00315.79
7.1.300.0060.00715.89
7.1.290.0060.00615.62
7.1.280.0110.00015.73
7.1.270.0030.01015.84
7.1.260.0030.00716.00
7.1.250.0070.01015.84
7.1.240.0100.00316.00
7.1.230.0070.00315.84
7.1.220.0130.00315.76
7.1.210.0030.01015.93
7.1.200.0050.00915.99
7.1.190.0090.00315.91
7.1.180.0030.01015.71
7.1.170.0070.00715.98
7.1.160.0080.00515.82
7.1.150.0060.00315.62
7.1.140.0060.00315.88
7.1.130.0060.00615.58
7.1.120.0070.00715.74
7.1.110.0030.01015.85
7.1.100.0040.00916.83
7.1.90.0030.01015.58
7.1.80.0060.00615.71
7.1.70.0020.01116.59
7.1.60.0110.00817.62
7.1.50.0090.00916.23
7.1.40.0090.00315.99
7.1.30.0120.00315.64
7.1.20.0060.00615.78
7.1.10.0090.00615.84
7.1.00.0030.02018.98
7.0.330.0060.01015.23
7.0.320.0040.00415.18
7.0.310.0100.00715.12
7.0.300.0030.00915.10
7.0.290.0080.00815.33
7.0.280.0050.00315.25
7.0.270.0030.01015.48
7.0.260.0080.00415.23
7.0.250.0000.01415.18
7.0.240.0030.00715.21
7.0.230.0040.01115.63
7.0.220.0030.01015.52
7.0.210.0080.00415.32
7.0.200.0160.00915.04
7.0.190.0120.00315.56
7.0.180.0030.00615.47
7.0.170.0060.00615.39
7.0.160.0030.01215.28
7.0.150.0140.00015.57
7.0.140.0020.04018.78
7.0.130.0030.00715.48
7.0.120.0000.01015.36
7.0.110.0070.00715.47
7.0.100.0040.01215.41
7.0.90.0040.00715.62
7.0.80.0300.03117.76
7.0.70.0100.04517.83
7.0.60.0170.04617.62
7.0.50.0340.02517.97
7.0.40.0070.04216.82
7.0.30.0050.04516.82
7.0.20.0030.03516.68
7.0.10.0030.04116.80
7.0.00.0070.04916.77
5.6.400.0060.00914.11
5.6.390.0070.00714.42
5.6.380.0000.01714.33
5.6.370.0070.00714.45
5.6.360.0040.00714.73
5.6.350.0050.00514.45
5.6.340.0140.00014.75
5.6.330.0040.00714.49
5.6.320.0030.00714.82
5.6.310.0100.00314.80
5.6.300.0030.00714.35
5.6.290.0030.01014.33
5.6.280.0050.04217.79
5.6.270.0000.01214.42
5.6.260.0040.00814.39
5.6.250.0060.00614.68
5.6.240.0060.00614.54
5.6.230.0080.04217.49
5.6.220.0110.04117.63
5.6.210.0070.03717.72
5.6.200.0030.05217.75
5.6.190.0130.04217.82
5.6.180.0020.03817.67
5.6.170.0070.02817.74
5.6.160.0090.03017.65
5.6.150.0100.04317.81
5.6.140.0080.04317.72
5.6.130.0050.04317.81
5.6.120.0100.04817.94
5.6.110.0140.02617.77
5.6.100.0070.03717.87
5.6.90.0050.04217.85
5.6.80.0030.02917.42
5.6.70.0070.02617.44
5.6.60.0150.03217.44
5.6.50.0080.04017.37
5.6.40.0080.04017.43
5.6.30.0030.02617.41
5.6.20.0070.03017.37
5.6.10.0090.04117.37
5.6.00.0050.04417.42
5.5.380.0090.00314.56
5.5.370.0080.04517.47
5.5.360.0060.02617.60
5.5.350.0060.02517.50
5.5.340.0060.04917.77
5.5.330.0070.04117.73
5.5.320.0100.04217.72
5.5.310.0100.04317.68
5.5.300.0070.04517.58
5.5.290.0080.04517.67
5.5.280.0070.04917.56
5.5.270.0020.04017.78
5.5.260.0030.04617.54
5.5.250.0070.03317.68
5.5.240.0110.03917.30
5.5.230.0100.03017.31
5.5.220.0030.03317.35
5.5.210.0050.03217.45
5.5.200.0070.04517.33
5.5.190.0070.02517.32
5.5.180.0100.02017.26
5.5.170.0040.00814.53
5.5.160.0100.04217.40
5.5.150.0070.04217.44
5.5.140.0000.03817.33
5.5.130.0090.03917.16
5.5.120.0080.04317.23
5.5.110.0040.04417.32
5.5.100.0060.04517.28
5.5.90.0080.04317.32
5.5.80.0080.02617.17
5.5.70.0110.03817.31
5.5.60.0080.02617.29
5.5.50.0100.03517.36
5.5.40.0100.03217.36
5.5.30.0070.04017.16
5.5.20.0120.03717.23
5.5.10.0080.04017.22
5.5.00.0070.04217.17
5.4.450.0050.02715.34
5.4.440.0050.03415.32
5.4.430.0040.02815.18
5.4.420.0050.04215.11
5.4.410.0030.03815.24
5.4.400.0030.04314.95
5.4.390.0090.02715.19
5.4.380.0070.02314.99
5.4.370.0060.02415.12
5.4.360.0030.03515.02
5.4.350.0030.03015.04
5.4.340.0070.04015.20
5.4.330.0030.00311.03
5.4.320.0100.02915.06
5.4.310.0050.03715.01
5.4.300.0070.02515.19
5.4.290.0050.04215.16
5.4.280.0060.04415.12
5.4.270.0070.04015.04
5.4.260.0100.03715.29
5.4.250.0060.04015.25
5.4.240.0050.02015.09
5.4.230.0050.02715.02
5.4.220.0120.03515.04
5.4.210.0060.02815.06
5.4.200.0050.03015.22
5.4.190.0090.02315.09
5.4.180.0030.03315.07
5.4.170.0080.03715.16
5.4.160.0060.04315.13
5.4.150.0050.04315.19
5.4.140.0040.03413.87
5.4.130.0030.03013.83
5.4.120.0050.02813.72
5.4.110.0000.04313.69
5.4.100.0050.03613.66
5.4.90.0050.04113.87
5.4.80.0080.03613.97
5.4.70.0010.02613.79
5.4.60.0030.04413.76
5.4.50.0060.03013.90
5.4.40.0040.02813.79
5.4.30.0000.02513.71
5.4.20.0090.02913.88
5.4.10.0030.04313.79
5.4.00.0070.03513.65
5.3.290.0060.04112.42
5.3.280.0050.04112.54
5.3.270.0060.02512.54
5.3.260.0020.04212.46
5.3.250.0030.04112.50
5.3.240.0070.03712.45
5.3.230.0050.04412.27
5.3.220.0070.03912.34
5.3.210.0050.02812.24
5.3.200.0020.03012.50
5.3.190.0030.03812.25
5.3.180.0000.03412.36
5.3.170.0020.03312.54
5.3.160.0070.03812.49
5.3.150.0050.03812.52
5.3.140.0050.04212.34
5.3.130.0030.02912.42
5.3.120.0070.02612.52
5.3.110.0110.03012.42
5.3.100.0020.03812.23
5.3.90.0050.04012.21
5.3.80.0050.03812.18
5.3.70.0110.03311.96
5.3.60.0030.03212.24
5.3.50.0060.02512.14
5.3.40.0050.02912.10
5.3.30.0000.03112.01
5.3.20.0080.03311.94
5.3.10.0030.03311.84
5.3.00.0080.03711.88
5.2.170.0030.05011.62
5.2.160.0130.03311.62
5.2.150.0100.06311.62
5.2.140.0130.05311.62
5.2.130.0030.04311.62
5.2.120.0070.06311.62
5.2.110.0070.06011.62
5.2.100.0070.06011.62
5.2.90.0100.04011.62
5.2.80.0030.07711.62
5.2.70.0000.06311.62
5.2.60.0070.06311.62
5.2.50.0030.06011.62
5.2.40.0070.06011.62
5.2.30.0070.05711.62
5.2.20.0030.06011.62
5.2.10.0000.05711.62
5.2.00.0030.03711.62
5.1.60.0000.03011.62
5.1.50.0000.05311.62
5.1.40.0000.04011.62
5.1.30.0030.06011.62
5.1.20.0000.03711.62
5.1.10.0000.05711.62
5.1.00.0070.04711.62
5.0.50.0070.03711.62
5.0.40.0070.02311.62
5.0.30.0030.05711.62
5.0.20.0030.03711.62
5.0.10.0000.04711.62
5.0.00.0070.06311.62
4.4.90.0030.02311.62
4.4.80.0000.03311.62
4.4.70.0070.01311.62
4.4.60.0000.02011.62
4.4.50.0000.03311.62
4.4.40.0030.05311.62
4.4.30.0070.01311.62
4.4.20.0000.03711.62
4.4.10.0070.03311.62
4.4.00.0000.04311.62
4.3.110.0070.02711.62
4.3.100.0000.02311.62
4.3.90.0000.02711.62
4.3.80.0030.05011.62
4.3.70.0030.03311.62
4.3.60.0000.03011.62
4.3.50.0000.03711.62
4.3.40.0070.05011.62
4.3.30.0000.03711.62
4.3.20.0000.03711.62
4.3.10.0070.03011.62
4.3.00.0000.03711.62

preferences:
53.57 ms | 401 KiB | 5 Q