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) { print_r($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)
5.4.160.0200.04312.41
5.4.150.0310.07312.39
5.4.140.0160.04212.09
5.4.130.0130.04512.06
5.4.120.0220.06512.03
5.4.110.0260.06312.03
5.4.100.0150.04312.03
5.4.90.0140.04512.03
5.4.80.0210.06712.03
5.4.70.0220.06812.02
5.4.60.0160.07112.02
5.4.50.0220.06512.02
5.4.40.0200.03612.01
5.4.30.0160.04212.01
5.4.20.0150.05812.00
5.4.10.0150.07112.01
5.4.00.0160.04211.50
5.3.260.0150.04512.72
5.3.250.0130.04712.72
5.3.240.0660.05712.72
5.3.230.0210.08112.71
5.3.220.0300.07512.68
5.3.210.0230.03912.68
5.3.200.0180.04212.68
5.3.190.0250.03812.67
5.3.180.0210.05412.68
5.3.170.0150.04412.67
5.3.160.0250.08012.67
5.3.150.0100.04912.67
5.3.140.0160.04312.66
5.3.130.0140.04512.65
5.3.120.0260.06512.66
5.3.110.0170.04312.66
5.3.100.0090.05012.12
5.3.90.0120.04512.09
5.3.80.0300.08612.09
5.3.70.0260.06512.08
5.3.60.0140.04512.07
5.3.50.0200.07012.01
5.3.40.0130.04512.01
5.3.30.0230.06311.98
5.3.20.0270.06011.76
5.3.10.0230.05111.72
5.3.00.0140.04211.71

preferences:
142.65 ms | 1394 KiB | 7 Q