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.40.0110.01118.82
8.3.30.0040.01119.01
8.3.20.0040.00420.34
8.3.10.0040.00421.97
8.3.00.0040.00422.21
8.2.170.0070.00722.96
8.2.160.0110.00422.08
8.2.150.0080.00024.18
8.2.140.0080.00024.66
8.2.130.0080.00026.16
8.2.120.0050.00317.75
8.2.110.0080.00022.24
8.2.100.0110.00017.62
8.2.90.0000.00819.08
8.2.80.0040.00418.03
8.2.70.0080.00017.47
8.2.60.0040.00418.03
8.2.50.0040.00418.07
8.2.40.0040.00418.16
8.2.30.0070.00018.00
8.2.20.0040.00417.79
8.2.10.0050.00317.75
8.2.00.0040.00417.73
8.1.270.0070.00022.13
8.1.260.0080.00026.35
8.1.250.0070.01128.09
8.1.240.0050.00523.82
8.1.230.0110.00018.91
8.1.220.0080.00017.74
8.1.210.0030.00618.77
8.1.200.0030.00717.22
8.1.190.0000.00817.51
8.1.180.0040.00418.10
8.1.170.0030.00518.33
8.1.160.0000.00822.05
8.1.150.0000.00718.61
8.1.140.0030.00617.48
8.1.130.0070.00017.71
8.1.120.0040.00417.41
8.1.110.0000.00717.39
8.1.100.0060.00317.50
8.1.90.0050.00217.46
8.1.80.0070.00017.37
8.1.70.0030.00317.45
8.1.60.0060.00317.61
8.1.50.0040.00417.57
8.1.40.0110.00017.50
8.1.30.0030.00617.61
8.1.20.0030.00617.56
8.1.10.0000.00817.55
8.1.00.0030.00617.47
8.0.300.0000.00718.77
8.0.290.0060.00316.93
8.0.280.0070.00018.37
8.0.270.0030.00317.34
8.0.260.0050.00316.95
8.0.250.0000.00716.96
8.0.240.0050.00216.94
8.0.230.0080.00017.09
8.0.220.0040.00416.91
8.0.210.0070.00016.91
8.0.200.0040.00417.03
8.0.190.0040.00417.10
8.0.180.0040.00417.02
8.0.170.0040.00416.91
8.0.160.0000.00716.96
8.0.150.0040.00417.05
8.0.140.0040.00416.97
8.0.130.0060.00013.41
8.0.120.0030.00516.84
8.0.110.0050.00217.00
8.0.100.0040.00416.85
8.0.90.0070.00017.11
8.0.80.0080.01416.96
8.0.70.0000.00816.91
8.0.60.0040.00416.95
8.0.50.0000.00716.84
8.0.30.0110.00817.18
8.0.20.0070.01217.40
8.0.10.0050.00317.02
8.0.00.0140.00816.65
7.4.330.0050.00015.08
7.4.320.0030.00316.74
7.4.300.0030.00316.51
7.4.290.0040.00416.61
7.4.280.0030.00316.66
7.4.270.0070.00316.55
7.4.260.0040.00416.64
7.4.250.0020.00516.51
7.4.240.0040.00416.61
7.4.230.0000.00716.39
7.4.220.0030.01416.43
7.4.210.0050.01116.59
7.4.200.0000.00716.73
7.4.190.0040.00416.81
7.4.160.0080.00816.60
7.4.150.0070.01017.40
7.4.140.0120.00517.86
7.4.130.0120.00816.58
7.4.120.0110.00716.57
7.4.110.0060.01116.82
7.4.100.0040.01516.75
7.4.90.0150.00316.65
7.4.80.0190.00316.68
7.4.70.0090.00916.57
7.4.60.0100.00616.63
7.4.50.0090.00016.54
7.4.40.0060.00822.77
7.4.30.0160.00216.33
7.4.10.0090.01015.21
7.4.00.0070.01115.09
7.3.330.0000.00513.35
7.3.320.0000.00513.49
7.3.310.0040.00416.35
7.3.300.0030.00316.36
7.3.290.0100.00716.38
7.3.280.0090.00616.41
7.3.270.0090.00917.40
7.3.260.0060.01316.53
7.3.250.0150.00316.56
7.3.240.0110.00716.73
7.3.230.0130.00416.44
7.3.210.0090.00916.61
7.3.200.0110.00819.39
7.3.190.0070.01116.70
7.3.180.0090.00616.46
7.3.170.0030.01216.52
7.3.160.0170.00016.63
7.3.130.0060.01315.02
7.3.120.0040.01314.89
7.3.110.0030.01715.11
7.3.100.0030.01214.69
7.3.90.0150.00314.86
7.3.80.0060.01314.70
7.3.70.0060.00914.88
7.3.60.0090.00615.02
7.3.50.0040.00714.86
7.3.40.0060.00914.86
7.3.30.0100.00714.91
7.3.20.0100.00316.74
7.3.10.0100.00616.59
7.3.00.0040.00416.85
7.2.330.0180.00016.62
7.2.320.0120.01216.75
7.2.310.0100.00616.52
7.2.300.0100.00616.74
7.2.290.0050.01116.71
7.2.260.0030.01615.29
7.2.250.0090.00614.95
7.2.240.0070.00715.26
7.2.230.0130.00314.79
7.2.220.0030.01015.08
7.2.210.0000.01115.25
7.2.200.0070.01015.05
7.2.190.0040.01415.26
7.2.180.0030.01315.07
7.2.170.0030.01315.13
7.2.160.0110.00315.25
7.2.150.0000.01316.90
7.2.140.0100.00616.92
7.2.130.0100.00616.76
7.2.120.0090.00616.96
7.2.110.0000.01316.95
7.2.100.0120.00316.97
7.2.90.0100.00616.93
7.2.80.0040.01416.94
7.2.70.0000.01116.75
7.2.60.0100.00516.83
7.2.50.0040.01116.78
7.2.40.0070.00716.75
7.2.30.0030.01317.10
7.2.20.0100.00316.95
7.2.10.0040.01116.86
7.2.00.0070.00618.27
7.1.330.0030.01015.58
7.1.320.0040.01415.94
7.1.310.0100.00616.15
7.1.300.0090.00615.85
7.1.290.0090.00616.02
7.1.280.0070.00715.81
7.1.270.0040.00415.78
7.1.260.0080.00815.56
7.1.250.0040.00715.63
7.1.240.0090.00615.90
7.1.230.0040.01115.49
7.1.220.0000.01015.70
7.1.210.0030.01015.80
7.1.200.0040.01315.80
7.1.190.0000.00915.51
7.1.180.0090.00315.54
7.1.170.0070.00715.86
7.1.160.0040.00715.86
7.1.150.0110.00015.55
7.1.140.0060.00615.92
7.1.130.0080.00315.54
7.1.120.0000.01015.91
7.1.110.0110.00415.91
7.1.100.0040.00415.98
7.1.90.0000.00915.50
7.1.80.0100.00315.84
7.1.70.0050.00416.64
7.1.60.0030.00816.47
7.1.50.0020.01416.55
7.1.40.0000.01615.87
7.1.30.0000.01115.74
7.1.20.0040.01115.98
7.1.10.0000.01415.73
7.1.00.0030.04119.16
7.0.330.0030.01015.22
7.0.320.0060.00615.34
7.0.310.0060.01015.47
7.0.300.0030.00615.24
7.0.290.0030.00915.36
7.0.280.0040.01115.53
7.0.270.0000.00815.44
7.0.260.0030.01015.53
7.0.250.0070.00715.27
7.0.240.0040.00415.46
7.0.230.0030.00715.43
7.0.220.0090.00415.54
7.0.210.0090.00015.36
7.0.200.0050.00716.03
7.0.190.0000.01115.44
7.0.180.0060.00915.45
7.0.170.0080.00515.47
7.0.160.0030.00615.19
7.0.150.0000.01415.14
7.0.140.0050.04018.60
7.0.130.0090.00615.24
7.0.120.0080.00015.56
7.0.110.0040.01115.48
7.0.100.0070.04717.63
7.0.90.0030.05017.83
7.0.80.0030.03617.69
7.0.70.0050.04717.70
7.0.60.0100.02317.70
7.0.50.0050.02817.95
7.0.40.0050.03416.80
7.0.30.0030.04316.73
7.0.20.0020.03016.84
7.0.10.0020.04416.65
7.0.00.0080.03816.73
5.6.400.0040.00814.34
5.6.390.0000.01414.77
5.6.380.0030.01414.54
5.6.370.0090.00614.69
5.6.360.0030.00614.38
5.6.350.0060.00614.31
5.6.340.0090.00614.64
5.6.330.0120.00314.45
5.6.320.0100.00714.31
5.6.310.0060.01214.45
5.6.300.0030.00714.65
5.6.290.0070.00714.60
5.6.280.0030.03817.61
5.6.270.0090.00314.66
5.6.260.0000.00814.58
5.6.250.0100.03217.56
5.6.240.0100.02617.63
5.6.230.0010.02617.65
5.6.220.0060.02817.56
5.6.210.0100.04017.61
5.6.200.0030.04617.85
5.6.190.0100.04317.77
5.6.180.0070.02817.87
5.6.170.0050.03717.66
5.6.160.0080.04217.79
5.6.150.0070.04817.75
5.6.140.0020.03417.74
5.6.130.0060.04817.92
5.6.120.0050.03817.77
5.6.110.0070.04617.74
5.6.100.0080.03317.70
5.6.90.0040.03917.63
5.6.80.0080.04417.31
5.6.70.0100.03117.35
5.6.60.0020.03117.33
5.6.50.0140.02017.59
5.6.40.0080.03417.42
5.6.30.0050.04317.41
5.6.20.0040.03117.44
5.6.10.0070.03117.40
5.6.00.0050.02317.38
5.5.380.0100.04317.31
5.5.370.0150.02017.52
5.5.360.0060.04417.56
5.5.350.0060.04317.42
5.5.340.0110.04017.65
5.5.330.0090.03517.66
5.5.320.0080.03317.55
5.5.310.0020.04717.60
5.5.300.0070.04517.56
5.5.290.0080.04217.79
5.5.280.0050.03817.60
5.5.270.0050.04117.82
5.5.260.0100.04617.53
5.5.250.0080.04217.61
5.5.240.0110.03517.30
5.5.230.0030.03617.18
5.5.220.0080.04517.11
5.5.210.0080.03017.44
5.5.200.0030.02917.32
5.5.190.0060.03717.26
5.5.180.0000.03217.33
5.5.170.0060.00614.56
5.5.160.0080.04017.19
5.5.150.0030.02517.45
5.5.140.0120.03217.31
5.5.130.0080.04217.28
5.5.120.0050.03317.31
5.5.110.0050.04617.20
5.5.100.0070.03717.17
5.5.90.0100.04017.15
5.5.80.0150.02417.03
5.5.70.0050.02317.05
5.5.60.0080.04617.27
5.5.50.0030.03017.23
5.5.40.0050.02217.14
5.5.30.0070.04517.27
5.5.20.0070.04417.37
5.5.10.0100.03317.11
5.5.00.0050.04217.12
5.4.450.0020.03015.58
5.4.440.0080.01815.58
5.4.430.0080.02715.58
5.4.420.0030.04015.51
5.4.410.0040.03715.60
5.4.400.0030.02515.42
5.4.390.0070.02815.47
5.4.380.0080.02315.50
5.4.370.0070.04115.41
5.4.360.0030.03015.32
5.4.350.0080.04315.51
5.4.340.0090.04415.49
5.4.330.0030.00911.79
5.4.320.0070.01815.34
5.4.310.0080.03215.39
5.4.300.0120.02515.48
5.4.290.0050.04515.41
5.4.280.0050.04115.49
5.4.270.0030.04115.37
5.4.260.0070.04215.46
5.4.250.0050.03915.46
5.4.240.0020.02515.44
5.4.230.0050.04015.47
5.4.220.0070.04315.46
5.4.210.0060.02515.46
5.4.200.0050.04015.37
5.4.190.0070.03015.37
5.4.180.0070.02915.46
5.4.170.0050.03815.34
5.4.160.0000.04415.40
5.4.150.0030.02715.45
5.4.140.0060.02014.03
5.4.130.0050.02714.10
5.4.120.0050.02814.10
5.4.110.0050.04014.08
5.4.100.0050.04014.18
5.4.90.0070.04214.16
5.4.80.0030.03314.05
5.4.70.0080.03814.16
5.4.60.0070.03914.07
5.4.50.0030.03014.11
5.4.40.0050.03614.15
5.4.30.0060.01914.12
5.4.20.0050.04014.10
5.4.10.0060.04314.14
5.4.00.0020.03213.82
5.3.290.0030.04313.22
5.3.280.0080.02813.21
5.3.270.0060.03513.18
5.3.260.0070.03913.25
5.3.250.0030.03413.16
5.3.240.0050.03413.16
5.3.230.0070.02013.21
5.3.220.0020.04013.17
5.3.210.0050.04213.20
5.3.200.0070.03813.23
5.3.190.0080.02413.18
5.3.180.0020.04313.21
5.3.170.0050.02213.25
5.3.160.0050.02513.15
5.3.150.0060.03913.19
5.3.140.0040.02513.24
5.3.130.0020.03013.15
5.3.120.0020.03913.16
5.3.110.0060.04313.13
5.3.100.0100.03412.97
5.3.90.0030.03012.92
5.3.80.0060.03312.93
5.3.70.0070.03312.92
5.3.60.0070.03712.86
5.3.50.0040.02412.95
5.3.40.0030.04112.88
5.3.30.0080.03712.80
5.3.20.0030.03312.79
5.3.10.0030.02512.76
5.3.00.0030.02612.78
5.2.170.0030.06711.01
5.2.160.0130.03311.21
5.2.150.0030.06711.18
5.2.140.0000.03311.06
5.2.130.0070.06010.96
5.2.120.0130.05010.91
5.2.110.0130.04311.12
5.2.100.0030.05011.16
5.2.90.0070.03010.94
5.2.80.0070.04010.91
5.2.70.0030.06311.06
5.2.60.0070.04010.97
5.2.50.0100.04711.04
5.2.40.0070.06310.79
5.2.30.0100.06010.80
5.2.20.0000.03310.95
5.2.10.0000.03710.86
5.2.00.0030.05710.78
5.1.60.0100.04310.05
5.1.50.0130.04710.01
5.1.40.0100.0479.82
5.1.30.0070.04710.36
5.1.20.0100.04310.37
5.1.10.0030.0409.90
5.1.00.0070.02710.07
5.0.50.0030.0238.57
5.0.40.0000.0208.40
5.0.30.0000.0508.23
5.0.20.0100.0378.18
5.0.10.0030.0438.16
5.0.00.0000.0338.19
4.4.90.0030.0307.48
4.4.80.0070.0277.48
4.4.70.0000.0237.48
4.4.60.0070.0307.48
4.4.50.0070.0137.48
4.4.40.0030.0237.48
4.4.30.0000.0337.48
4.4.20.0000.0307.48
4.4.10.0000.0177.48
4.4.00.0000.0307.48
4.3.110.0000.0207.48
4.3.100.0030.0237.48
4.3.90.0030.0337.48
4.3.80.0000.0577.48
4.3.70.0000.0177.48
4.3.60.0030.0207.48
4.3.50.0030.0337.48
4.3.40.0030.0477.48
4.3.30.0030.0207.48
4.3.20.0070.0137.48
4.3.10.0000.0277.48
4.3.00.0000.0177.48

preferences:
40.71 ms | 400 KiB | 5 Q