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) { // 暂时我们只打算以纯文本的形式展示信息 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_keys1();

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.00616.75
8.3.50.0110.00816.80
8.3.40.0120.00618.97
8.3.30.0070.00718.84
8.3.20.0040.00418.73
8.3.10.0080.00818.76
8.3.00.0050.00519.38
8.2.180.0150.00616.88
8.2.170.0110.00322.96
8.2.160.0040.01119.08
8.2.150.0070.01424.18
8.2.140.0090.00024.66
8.2.130.0080.00026.16
8.2.120.0040.00420.96
8.2.110.0030.00720.97
8.2.100.0040.00819.64
8.2.90.0040.00419.17
8.2.80.0080.00017.97
8.2.70.0080.00017.48
8.2.60.0080.00018.16
8.2.50.0040.00418.10
8.2.40.0000.00822.31
8.2.30.0000.00819.23
8.2.20.0080.00317.74
8.2.10.0040.00417.79
8.2.00.0000.00817.93
8.1.280.0090.00625.92
8.1.270.0040.00423.99
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0030.00621.34
8.1.230.0120.00019.23
8.1.220.0000.01117.77
8.1.210.0000.00818.77
8.1.200.0060.00317.47
8.1.190.0060.00317.36
8.1.180.0000.00818.10
8.1.170.0040.00418.81
8.1.160.0030.00519.18
8.1.150.0070.00018.81
8.1.140.0040.00417.45
8.1.130.0050.00317.51
8.1.120.0080.00017.42
8.1.110.0070.00017.54
8.1.100.0000.00717.46
8.1.90.0030.00517.48
8.1.80.0000.00817.53
8.1.70.0000.00717.46
8.1.60.0030.00617.63
8.1.50.0040.00417.52
8.1.40.0090.00017.46
8.1.30.0060.00317.73
8.1.20.0030.00617.60
8.1.10.0030.00617.59
8.1.00.0080.00017.58
8.0.300.0040.00418.77
8.0.290.0060.00317.00
8.0.280.0030.00318.37
8.0.270.0000.00717.42
8.0.260.0020.00516.90
8.0.250.0040.00417.10
8.0.240.0030.00516.96
8.0.230.0050.00317.07
8.0.220.0000.00817.04
8.0.210.0030.00616.92
8.0.200.0030.00316.98
8.0.190.0000.00816.98
8.0.180.0080.00017.03
8.0.170.0080.00016.91
8.0.160.0040.00417.11
8.0.150.0020.00516.99
8.0.140.0080.00016.94
8.0.130.0000.00513.39
8.0.120.0050.00316.89
8.0.110.0050.00216.92
8.0.100.0000.00716.91
8.0.90.0000.00817.05
8.0.80.0100.01017.08
8.0.70.0040.00416.92
8.0.60.0060.00316.91
8.0.50.0040.00417.05
8.0.30.0070.01416.89
8.0.20.0140.00517.21
8.0.10.0000.00717.12
8.0.00.0040.01416.87
7.4.330.0020.00213.03
7.4.320.0030.00316.46
7.4.300.0040.00416.59
7.4.290.0000.00716.63
7.4.280.0000.00716.66
7.4.270.0000.00816.66
7.4.260.0030.00313.31
7.4.250.0030.00616.59
7.4.240.0000.00716.67
7.4.230.0080.00016.67
7.4.220.0100.01716.70
7.4.210.0030.01216.66
7.4.200.0070.00016.54
7.4.190.0040.00416.61
7.4.160.0030.01316.55
7.4.150.0060.01216.79
7.4.140.0120.00617.86
7.4.130.0120.00916.71
7.4.120.0070.01016.66
7.4.110.0030.01716.55
7.4.100.0070.01316.63
7.4.90.0090.00916.71
7.4.80.0090.01219.39
7.4.70.0160.00616.64
7.4.60.0160.00016.45
7.4.50.0000.00616.33
7.4.40.0070.01116.35
7.4.30.0100.01016.54
7.4.10.0070.01016.53
7.4.00.0030.01315.89
7.3.330.0000.00613.45
7.3.320.0000.00713.50
7.3.310.0040.00416.49
7.3.300.0030.00316.55
7.3.290.0120.00316.50
7.3.280.0000.01416.50
7.3.270.0070.01016.59
7.3.260.0120.00616.49
7.3.240.0040.01316.65
7.3.230.0060.01516.41
7.3.210.0100.00716.62
7.3.200.0130.00316.53
7.3.190.0050.01316.68
7.3.180.0110.00716.71
7.3.170.0100.00716.43
7.3.160.0090.00916.43
7.3.130.0040.01116.73
7.3.120.0090.01115.46
7.3.110.0060.01216.30
7.3.100.0030.01416.30
7.3.90.0060.01016.43
7.3.80.0040.00716.43
7.3.70.0060.00616.47
7.3.60.0070.00316.45
7.3.50.0030.00616.37
7.3.40.0060.01316.24
7.3.30.0060.01216.36
7.3.20.0090.00617.98
7.3.10.0100.00318.09
7.3.00.0110.00718.11
7.2.330.0130.00416.86
7.2.320.0120.01216.53
7.2.310.0030.02016.76
7.2.300.0190.00516.86
7.2.290.0150.00316.86
7.2.260.0060.01316.57
7.2.250.0190.00316.82
7.2.240.0060.00916.77
7.2.230.0090.00916.66
7.2.220.0060.01316.65
7.2.210.0100.00716.65
7.2.200.0000.01116.75
7.2.190.0030.00616.63
7.2.180.0080.00616.59
7.2.170.0090.00916.65
7.2.160.0030.01416.64
7.2.150.0070.01018.45
7.2.140.0060.00918.55
7.2.130.0100.00718.64
7.2.120.0040.01118.54
7.2.110.0040.01118.43
7.2.100.0100.00718.45
7.2.90.0070.00718.49
7.2.80.0070.00718.40
7.2.70.0090.00618.50
7.2.60.0080.00617.74
7.2.50.0100.00718.47
7.2.40.0070.00718.62
7.2.30.0120.00618.58
7.2.20.0070.00718.46
7.2.10.0100.00718.26
7.2.00.0070.01318.47
7.1.330.0100.00717.26
7.1.320.0060.01017.47
7.1.310.0060.00617.61
7.1.300.0060.00317.37
7.1.290.0030.01017.32
7.1.280.0000.01617.29
7.1.270.0030.01017.40
7.1.260.0030.01217.45
7.1.250.0070.01017.23
7.1.240.0060.00617.47
7.1.230.0120.00317.40
7.1.220.0090.00617.41
7.1.210.0030.01017.31
7.1.200.0060.00716.73
7.1.190.0030.00617.36
7.1.180.0040.01117.38
7.1.170.0060.01217.14
7.1.160.0000.01017.48
7.1.150.0030.00917.32
7.1.140.0060.00917.41
7.1.130.0110.00717.44
7.1.120.0000.01217.27
7.1.110.0070.01017.45
7.1.100.0100.00317.26
7.1.90.0100.00717.48
7.1.80.0030.01017.61
7.1.70.0060.00417.27
7.1.60.0070.01218.40
7.1.50.0050.00517.24
7.1.40.0040.01117.54
7.1.30.0070.00717.27
7.1.20.0030.01017.45
7.1.10.0100.00617.27
7.1.00.0040.04119.88
7.0.330.0100.00716.94
7.0.320.0070.00717.15
7.0.310.0110.00417.10
7.0.300.0120.00616.98
7.0.290.0060.00617.08
7.0.280.0040.01117.07
7.0.270.0040.01117.02
7.0.260.0030.01016.93
7.0.250.0000.01617.02
7.0.240.0140.00016.91
7.0.230.0070.00317.14
7.0.220.0060.00916.84
7.0.210.0060.00617.00
7.0.200.0060.00416.94
7.0.190.0040.01117.07
7.0.180.0040.00816.97
7.0.170.0000.01216.93
7.0.160.0070.00316.98
7.0.150.0030.00916.97
7.0.140.0050.04219.57
7.0.130.0060.01016.95
7.0.120.0070.04119.55
7.0.110.0030.01016.95
7.0.100.0090.00616.95
7.0.90.0030.00617.00
7.0.80.0100.00716.91
7.0.70.0060.00616.91
7.0.60.0060.02018.47
7.0.50.0030.02517.39
7.0.40.0050.02617.56
7.0.30.0190.02917.59
7.0.20.0120.02717.63
7.0.10.0100.04817.58
7.0.00.0100.04317.62
5.6.400.0090.00615.85
5.6.390.0000.01016.13
5.6.380.0030.01016.21
5.6.370.0060.00916.33
5.6.360.0060.00916.36
5.6.350.0070.00716.18
5.6.340.0030.00915.87
5.6.330.0130.00315.80
5.6.320.0000.01716.14
5.6.310.0060.00916.11
5.6.300.0070.01016.38
5.6.290.0120.00616.02
5.6.280.0020.04318.57
5.6.270.0140.00316.13
5.6.260.0070.01016.05
5.6.250.0070.00715.99
5.6.240.0120.00316.32
5.6.230.0090.00315.90
5.6.220.0030.01015.96
5.6.210.0050.03918.32
5.6.200.0090.04117.09
5.6.190.0100.04518.23
5.6.180.0150.04818.16
5.6.170.0250.04018.18
5.6.160.0050.03818.20
5.6.150.0050.04517.02
5.6.140.0070.03817.09
5.6.130.0030.03517.16
5.6.120.0070.04418.47
5.6.110.0080.04118.56
5.6.100.0030.03318.55
5.6.90.0080.04218.48
5.6.80.0100.04318.24
5.6.70.0060.00915.82
5.6.60.0060.00615.71
5.6.50.0030.01316.08
5.6.40.0090.00616.15
5.6.30.0000.01115.87
5.6.20.0070.00316.03
5.6.10.0080.00816.01
5.6.00.0040.01215.99
5.5.380.0100.00315.75
5.5.370.0070.01415.83
5.5.360.0030.01016.13
5.5.350.0070.04018.21
5.5.340.0040.02317.02
5.5.330.0050.04218.13
5.5.320.0030.04718.16
5.5.310.0190.03918.06
5.5.300.0050.04117.02
5.5.290.0100.04117.01
5.5.280.0080.02518.38
5.5.270.0100.04718.51
5.5.260.0130.04018.49
5.5.250.0100.04218.26
5.5.240.0130.02318.11
5.5.230.0070.00715.87
5.5.220.0030.00815.74
5.5.210.0000.01315.80
5.5.200.0090.00915.85
5.5.190.0040.01115.70
5.5.180.0030.01015.97
5.5.170.0080.00615.73
5.5.160.0000.01315.94
5.5.150.0060.00615.62
5.5.140.0030.00715.91
5.5.130.0070.00715.75
5.5.120.0030.01215.96
5.5.110.0120.00615.81
5.5.100.0120.00616.01
5.5.90.0100.00715.98
5.5.80.0030.01015.91
5.5.70.0090.00915.73
5.5.60.0040.01115.71
5.5.50.0040.00815.78
5.5.40.0100.00615.69
5.5.30.0130.00415.76
5.5.20.0040.00715.84
5.5.10.0090.00615.83
5.5.00.0030.00916.04
5.4.450.0270.02216.07
5.4.440.0290.02016.11
5.4.430.0270.04115.94
5.4.420.0460.02116.14
5.4.410.0450.02215.99
5.4.400.0340.02215.92
5.4.390.0250.02215.92
5.4.380.0380.01415.96
5.4.370.0050.02915.97
5.4.360.0510.02315.75
5.4.350.0330.02415.81
5.4.340.0360.02115.95
5.4.330.0030.01012.73
5.4.320.0380.02215.79
5.4.310.0130.02415.82
5.4.300.0360.02015.90
5.4.290.0550.01515.88
5.4.280.0450.02516.03
5.4.270.0350.02515.78
5.4.260.0270.02015.86
5.4.250.0260.02415.94
5.4.240.0520.02515.77
5.4.230.0400.02115.92
5.4.220.0180.02715.92
5.4.210.0400.01715.70
5.4.200.0070.02215.86
5.4.190.0280.02915.71
5.4.180.0150.02315.82
5.4.170.0370.02015.91
5.4.160.0270.02115.87
5.4.150.0210.02715.83
5.4.140.0450.02214.63
5.4.130.0420.01814.61
5.4.120.0160.02114.49
5.4.110.0270.03214.65
5.4.100.0310.02314.58
5.4.90.0350.02214.64
5.4.80.0250.02714.49
5.4.70.0430.01814.72
5.4.60.0150.02514.44
5.4.50.0150.02214.44
5.4.40.0400.01814.54
5.4.30.0320.02114.43
5.4.20.0350.02314.51
5.4.10.0390.01614.43
5.4.00.0380.02314.19
5.3.290.0900.03315.20
5.3.280.0370.06715.20
5.3.270.0570.03315.20
5.3.260.0270.04015.20
5.3.250.0500.04315.20
5.3.240.0600.03015.20
5.3.230.0400.04015.20
5.3.220.0400.04015.20
5.3.210.0530.04715.20
5.3.200.0570.04015.20
5.3.190.0570.04015.20
5.3.180.0670.03715.20
5.3.170.0570.05315.20
5.3.160.0570.03715.20
5.3.150.0500.03315.20
5.3.140.0600.03715.20
5.3.130.0730.04015.20
5.3.120.0870.04015.20
5.3.110.0400.04015.20
5.3.100.0670.03715.20
5.3.90.0370.03715.20
5.3.80.0170.03315.20
5.3.70.0670.04315.20
5.3.60.0770.03715.20
5.3.50.0270.04715.20
5.3.40.0800.03315.20
5.3.30.0500.02715.20
5.3.20.0600.03715.20
5.3.10.0630.03315.20
5.3.00.0330.04715.20
5.2.170.0430.02315.20
5.2.160.0300.03315.20
5.2.150.0270.03715.20
5.2.140.0100.02715.20
5.2.130.0200.04015.20
5.2.120.0400.03015.20
5.2.110.0270.03015.20
5.2.100.0670.02315.20
5.2.90.0230.02315.20
5.2.80.0430.03015.20
5.2.70.0800.03315.20
5.2.60.0430.03015.20
5.2.50.0470.02715.20
5.2.40.0230.03715.20
5.2.30.0300.02715.20
5.2.20.0100.03315.20
5.2.10.0230.03015.20
5.2.00.0230.03015.20
5.1.60.0330.03015.20
5.1.50.0170.03015.20
5.1.40.0170.02715.20
5.1.30.0470.03315.20
5.1.20.0200.03715.20
5.1.10.0130.03715.20
5.1.00.0530.02315.20
5.0.50.0030.02315.20
5.0.40.0130.01715.20
5.0.30.0200.03015.20
5.0.20.0200.01315.20
5.0.10.0000.01715.20
5.0.00.0070.03015.20
4.4.90.0100.01315.20
4.4.80.0200.01715.20
4.4.70.0130.01315.20
4.4.60.0170.01715.20
4.4.50.0130.02015.20
4.4.40.0170.02015.20
4.4.30.0300.00715.20
4.4.20.0370.01015.20
4.4.10.0100.01715.20
4.4.00.0100.02715.20
4.3.110.0200.02015.20
4.3.100.0130.01315.20
4.3.90.0130.01315.20
4.3.80.0270.03015.20
4.3.70.0270.01715.20
4.3.60.0000.01715.20
4.3.50.0200.01315.20
4.3.40.0300.01715.20
4.3.30.0030.02015.20
4.3.20.0030.01315.20
4.3.10.0070.01315.20
4.3.00.0070.03015.20

preferences:
56.96 ms | 401 KiB | 5 Q