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) 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.01216.74
8.3.50.0100.01017.34
8.3.40.0090.01218.84
8.3.30.0150.00018.66
8.3.20.0050.00318.77
8.3.10.0050.00320.53
8.3.00.0060.00319.38
8.2.180.0170.00316.63
8.2.170.0100.01022.96
8.2.160.0100.00320.83
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0070.00417.63
8.2.110.0060.00620.89
8.2.100.0000.01217.84
8.2.90.0060.00319.47
8.2.80.0050.00219.33
8.2.70.0000.00817.38
8.2.60.0000.00817.93
8.2.50.0070.00418.07
8.2.40.0050.00318.16
8.2.30.0090.00218.17
8.2.20.0040.00417.77
8.2.10.0080.00017.66
8.2.00.0040.00417.86
8.1.280.0090.00625.92
8.1.270.0040.00424.66
8.1.260.0030.00726.35
8.1.250.0000.00828.09
8.1.240.0060.00322.52
8.1.230.0060.00620.84
8.1.220.0060.00317.74
8.1.210.0030.00519.04
8.1.200.0040.00417.35
8.1.190.0030.00517.53
8.1.180.0050.00318.10
8.1.170.0060.00318.84
8.1.160.0050.00218.87
8.1.150.0000.00818.62
8.1.140.0030.00617.44
8.1.130.0050.00217.72
8.1.120.0000.00817.34
8.1.110.0020.00517.42
8.1.100.0080.00017.43
8.1.90.0050.00317.40
8.1.80.0040.00417.38
8.1.70.0030.00317.43
8.1.60.0000.00817.61
8.1.50.0000.00817.33
8.1.40.0040.00417.48
8.1.30.0000.00817.61
8.1.20.0070.00017.59
8.1.10.0050.00317.55
8.1.00.0030.00617.45
8.0.300.0090.00020.10
8.0.290.0040.00416.63
8.0.280.0000.00718.48
8.0.270.0030.00317.30
8.0.260.0080.00016.95
8.0.250.0050.00517.12
8.0.240.0050.00317.02
8.0.230.0040.00416.99
8.0.220.0070.00016.90
8.0.210.0000.00717.01
8.0.200.0000.00816.97
8.0.190.0030.00517.07
8.0.180.0100.00017.05
8.0.170.0000.00917.04
8.0.160.0000.00716.86
8.0.150.0000.00816.84
8.0.140.0030.00616.86
8.0.130.0030.00313.41
8.0.120.0030.00616.95
8.0.110.0000.00816.89
8.0.100.0040.00417.04
8.0.90.0080.00016.86
8.0.80.0060.01016.98
8.0.70.0000.00716.95
8.0.60.0080.00017.02
8.0.50.0050.00316.93
8.0.30.0120.00617.14
8.0.20.0140.00517.25
8.0.10.0000.00817.11
8.0.00.0090.00916.93
7.4.330.0000.00513.04
7.4.320.0060.00016.57
7.4.300.0060.00016.50
7.4.290.0000.00716.68
7.4.280.0000.00716.58
7.4.270.0000.00716.63
7.4.260.0030.00313.27
7.4.250.0030.00616.68
7.4.240.0030.00316.55
7.4.230.0030.00316.55
7.4.220.0060.01216.55
7.4.210.0070.00716.63
7.4.200.0040.00416.69
7.4.190.0060.00316.80
7.4.160.0090.00916.55
7.4.150.0110.00716.67
7.4.140.0080.01516.52
7.4.130.0090.00816.55
7.4.120.0080.01116.58
7.4.110.0090.00616.75
7.4.100.0100.00716.64
7.4.90.0100.01316.68
7.4.80.0090.01419.39
7.4.70.0160.00616.54
7.4.60.0150.00416.62
7.4.50.0030.00616.77
7.4.40.0040.00716.67
7.4.30.0090.00916.42
7.4.10.0070.01115.09
7.4.00.0050.01015.09
7.3.330.0000.00613.41
7.3.320.0060.00013.49
7.3.310.0000.00716.38
7.3.300.0040.00416.53
7.3.290.0130.01016.43
7.3.280.0080.01016.36
7.3.270.0100.00716.65
7.3.260.0100.01016.45
7.3.250.0130.00516.56
7.3.240.0110.00716.49
7.3.230.0100.01016.67
7.3.210.0070.01016.52
7.3.200.0060.01216.78
7.3.190.0090.00916.50
7.3.180.0100.00616.48
7.3.170.0090.00616.58
7.3.160.0180.00316.65
7.3.130.0000.01614.84
7.3.120.0070.01015.02
7.3.110.0070.00815.04
7.3.100.0110.00314.63
7.3.90.0070.00714.98
7.3.80.0090.00715.13
7.3.70.0030.00614.78
7.3.60.0070.00415.01
7.3.50.0040.01114.98
7.3.40.0090.00915.00
7.3.30.0120.00015.08
7.3.20.0100.00616.82
7.3.10.0090.00616.56
7.3.00.0080.00816.73
7.2.330.0110.00716.57
7.2.320.0110.00816.91
7.2.310.0110.01116.53
7.2.300.0090.00916.62
7.2.290.0100.01316.70
7.2.260.0140.00415.18
7.2.250.0090.01215.41
7.2.240.0040.01115.41
7.2.230.0000.01115.16
7.2.220.0030.00915.05
7.2.210.0000.01414.75
7.2.200.0000.01115.13
7.2.190.0060.00915.13
7.2.180.0060.00615.29
7.2.170.0070.01114.95
7.2.160.0070.00715.15
7.2.150.0090.00616.96
7.2.140.0130.00316.82
7.2.130.0060.00616.73
7.2.120.0090.00616.66
7.2.110.0000.01216.79
7.2.100.0040.01417.08
7.2.90.0000.01416.77
7.2.80.0090.00617.06
7.2.70.0070.00416.86
7.2.60.0030.01316.78
7.2.50.0170.00016.98
7.2.40.0000.01216.87
7.2.30.0030.01417.11
7.2.20.0100.00617.04
7.2.10.0050.00616.96
7.2.00.0030.01118.07
7.1.330.0060.00915.84
7.1.320.0060.00315.48
7.1.310.0070.01015.67
7.1.300.0060.00615.73
7.1.290.0090.00615.80
7.1.280.0000.01215.65
7.1.270.0090.00615.73
7.1.260.0140.00316.01
7.1.250.0060.01015.99
7.1.240.0060.00615.91
7.1.230.0070.00415.71
7.1.220.0040.00815.67
7.1.210.0080.00015.55
7.1.200.0030.00815.69
7.1.190.0000.01215.52
7.1.180.0030.01015.95
7.1.170.0040.00415.54
7.1.160.0060.00915.54
7.1.150.0030.01215.93
7.1.140.0060.00315.68
7.1.130.0000.01315.61
7.1.120.0070.00715.45
7.1.110.0140.00015.72
7.1.100.0070.00417.05
7.1.90.0040.00715.73
7.1.80.0090.00615.91
7.1.70.0080.00116.63
7.1.60.0060.01217.71
7.1.50.0050.01416.50
7.1.40.0100.00015.77
7.1.30.0030.00615.65
7.1.20.0080.00516.02
7.1.10.0030.01415.91
7.1.00.0050.03019.22
7.0.330.0030.01015.18
7.0.320.0000.01015.38
7.0.310.0090.00415.32
7.0.300.0090.00015.46
7.0.290.0040.01115.52
7.0.280.0030.01015.38
7.0.270.0000.01215.42
7.0.260.0060.01015.50
7.0.250.0040.00815.40
7.0.240.0030.01015.52
7.0.230.0080.00015.54
7.0.220.0040.00715.55
7.0.210.0060.00315.45
7.0.200.0660.00515.09
7.0.190.0070.00715.50
7.0.180.0060.00615.46
7.0.170.0030.00715.64
7.0.160.0030.01015.57
7.0.150.0040.00415.44
7.0.140.0050.04018.61
7.0.130.0070.00315.39
7.0.120.0030.03518.83
7.0.110.0000.01115.52
7.0.100.0070.00715.29
7.0.90.0040.00715.54
7.0.80.0100.00315.63
7.0.70.0030.00515.69
7.0.60.0070.04717.69
7.0.50.0030.02916.73
7.0.40.0050.02516.95
7.0.30.0150.04816.92
7.0.20.0170.02516.93
7.0.10.0080.02516.86
7.0.00.0030.04216.88
5.6.400.0030.01314.37
5.6.390.0030.00614.70
5.6.380.0030.00914.91
5.6.370.0030.00714.37
5.6.360.0070.00314.61
5.6.350.0000.01514.66
5.6.340.0060.01014.37
5.6.330.0060.00614.62
5.6.320.0070.00714.71
5.6.310.0060.00614.56
5.6.300.0000.00914.75
5.6.290.0040.01114.67
5.6.280.0050.04017.77
5.6.270.0030.00614.54
5.6.260.0030.01214.50
5.6.250.0100.00314.45
5.6.240.0000.00914.41
5.6.230.0000.01214.48
5.6.220.0060.00614.36
5.6.210.0060.02617.61
5.6.200.0050.04816.37
5.6.190.0100.04417.44
5.6.180.0130.02917.61
5.6.170.0170.04317.59
5.6.160.0080.02317.53
5.6.150.0020.03216.37
5.6.140.0030.03416.39
5.6.130.0070.04416.45
5.6.120.0080.04017.80
5.6.110.0080.05017.94
5.6.100.0020.04917.88
5.6.90.0080.04217.64
5.6.80.0070.04017.36
5.6.70.2030.01817.35
5.6.60.0070.00314.40
5.6.50.0060.00314.49
5.6.40.0070.00714.69
5.6.30.0070.00814.54
5.6.20.0070.00314.63
5.6.10.0030.01114.63
5.6.00.0030.00914.46
5.5.380.0000.01214.41
5.5.370.0070.00714.62
5.5.360.0070.01014.34
5.5.350.0150.04617.60
5.5.340.0020.02416.28
5.5.330.0100.03217.41
5.5.320.0300.03217.39
5.5.310.0200.04017.57
5.5.300.0020.03516.29
5.5.290.0100.04316.28
5.5.280.0050.02317.61
5.5.270.0090.04317.55
5.5.260.0080.03817.72
5.5.250.0070.03217.54
5.5.240.0160.04617.31
5.5.230.0060.00614.64
5.5.220.0060.00314.35
5.5.210.0030.00714.41
5.5.200.0060.00614.57
5.5.190.0030.00614.24
5.5.180.0100.00614.41
5.5.170.0070.01114.16
5.5.160.0100.00014.52
5.5.150.0040.01514.61
5.5.140.0090.00614.22
5.5.130.0080.00614.36
5.5.120.0040.00814.50
5.5.110.0030.01014.17
5.5.100.0030.01314.28
5.5.90.0030.01514.48
5.5.80.0030.00814.02
5.5.70.0140.00314.67
5.5.60.0110.00714.39
5.5.50.0110.00814.39
5.5.40.0130.00514.46
5.5.30.0040.01614.16
5.5.20.0100.01014.55
5.5.10.0110.00713.95
5.5.00.0140.00814.14
5.4.450.0050.03416.21
5.4.440.0050.03716.27
5.4.430.0030.02416.28
5.4.420.0050.02216.22
5.4.410.0050.03216.21
5.4.400.0050.03016.06
5.4.390.0070.02416.06
5.4.380.0030.04515.95
5.4.370.0030.02715.91
5.4.360.0020.04416.08
5.4.350.0070.03716.06
5.4.340.0000.03715.98
5.4.330.0060.00912.96
5.4.320.0100.04015.99
5.4.310.0040.03616.05
5.4.300.0070.02016.10
5.4.290.0050.03816.08
5.4.280.0080.02216.08
5.4.270.0070.02915.91
5.4.260.0090.03816.10
5.4.250.0020.04615.90
5.4.240.0070.02516.05
5.4.230.0060.03415.94
5.4.220.0130.03315.98
5.4.210.0030.03615.97
5.4.200.0020.03316.05
5.4.190.0070.04115.91
5.4.180.0030.04116.04
5.4.170.0110.03816.08
5.4.160.0120.02715.94
5.4.150.0040.02715.96
5.4.140.0090.03914.76
5.4.130.0070.04014.67
5.4.120.0070.03914.71
5.4.110.0040.02414.69
5.4.100.0050.04114.70
5.4.90.0040.04614.66
5.4.80.0070.03914.75
5.4.70.0090.02014.71
5.4.60.0100.03914.70
5.4.50.0050.02714.64
5.4.40.0050.04214.63
5.4.30.0110.03214.73
5.4.20.0090.03614.83
5.4.10.0000.04314.74
5.4.00.0050.02914.38
5.3.290.0040.02713.85
5.3.280.0070.04013.79
5.3.270.0100.03713.82
5.3.260.0060.02113.80
5.3.250.0070.02013.73
5.3.240.0050.02013.86
5.3.230.0030.03613.80
5.3.220.0070.03513.80
5.3.210.0100.02213.78
5.3.200.0040.02213.78
5.3.190.0100.03213.79
5.3.180.0020.03113.84
5.3.170.0050.02513.78
5.3.160.0020.02513.77
5.3.150.0020.03513.78
5.3.140.0040.02013.79
5.3.130.0030.02813.76
5.3.120.0090.04013.77
5.3.110.0050.03913.77
5.3.100.0060.04013.52
5.3.90.0030.02713.49
5.3.80.0050.01913.47
5.3.70.0040.02713.46
5.3.60.0020.02313.45
5.3.50.0030.02213.46
5.3.40.0060.03213.48
5.3.30.0080.02213.52
5.3.20.0010.03813.35
5.3.10.0050.03013.38
5.3.00.0040.04013.31
5.2.170.0100.05010.98
5.2.160.0030.03711.05
5.2.150.0030.06311.13
5.2.140.0030.03711.11
5.2.130.0170.02311.04
5.2.120.0100.03711.13
5.2.110.0100.02711.03
5.2.100.0070.03311.00
5.2.90.0030.03710.96
5.2.80.0070.05311.03
5.2.70.0000.06711.00
5.2.60.0070.04711.05
5.2.50.0100.05011.02
5.2.40.0070.05711.07
5.2.30.0030.04710.90
5.2.20.0100.05010.95
5.2.10.0030.03010.85
5.2.00.0000.06010.76
5.1.60.0070.04710.00
5.1.50.0000.0339.96
5.1.40.0070.0339.96
5.1.30.0000.03710.34
5.1.20.0030.02310.36
5.1.10.0070.0339.98
5.1.00.0070.03010.07
5.0.50.0030.0208.98
5.0.40.0070.0378.98
5.0.30.0030.0678.98
5.0.20.0030.0408.98
5.0.10.0030.0438.98
5.0.00.0070.0608.98
4.4.90.0000.0178.98
4.4.80.0030.0338.98
4.4.70.0030.0378.98
4.4.60.0030.0278.98
4.4.50.0070.0178.98
4.4.40.0000.0338.98
4.4.30.0000.0378.98
4.4.20.0030.0138.98
4.4.10.0030.0178.98
4.4.00.0170.0338.98
4.3.110.0030.0378.98
4.3.100.0000.0208.98
4.3.90.0000.0408.98
4.3.80.0030.0508.98
4.3.70.0000.0208.98
4.3.60.0030.0208.98
4.3.50.0100.0308.98
4.3.40.0070.0508.98
4.3.30.0030.0278.98
4.3.20.0030.0338.98
4.3.10.0030.0238.98
4.3.00.0000.0338.98

preferences:
37.81 ms | 401 KiB | 5 Q