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)
8.3.60.0150.00016.75
8.3.50.0140.00517.62
8.3.40.0120.00619.09
8.3.30.0150.00018.79
8.3.20.0050.00318.80
8.3.10.0090.00020.28
8.3.00.0040.00417.75
8.2.180.0070.01416.88
8.2.170.0120.00322.96
8.2.160.0070.00722.11
8.2.150.0050.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0030.00519.76
8.2.110.0060.00321.10
8.2.100.0000.01117.91
8.2.90.0030.00619.17
8.2.80.0040.00417.80
8.2.70.0070.00417.50
8.2.60.0030.00618.05
8.2.50.0080.00019.48
8.2.40.0050.00318.22
8.2.30.0040.00418.09
8.2.20.0000.00917.90
8.2.10.0000.00817.87
8.2.00.0040.00417.86
8.1.280.0110.00425.92
8.1.270.0070.00024.66
8.1.260.0000.00726.35
8.1.250.0040.00428.09
8.1.240.0090.00020.88
8.1.230.0000.01121.04
8.1.220.0040.00417.74
8.1.210.0060.00319.04
8.1.200.0070.00317.48
8.1.190.0040.00417.64
8.1.180.0040.00418.10
8.1.170.0080.00018.79
8.1.160.0070.00018.91
8.1.150.0040.00418.82
8.1.140.0090.00017.51
8.1.130.0030.00317.80
8.1.120.0040.00417.54
8.1.110.0080.00017.42
8.1.100.0030.00517.57
8.1.90.0030.00517.49
8.1.80.0000.00717.38
8.1.70.0000.00817.44
8.1.60.0040.00417.64
8.1.50.0000.00817.55
8.1.40.0000.00817.58
8.1.30.0000.00817.64
8.1.20.0030.00517.75
8.1.10.0030.00617.55
8.1.00.0000.00917.63
8.0.300.0060.00320.10
8.0.290.0000.00716.75
8.0.280.0070.00018.55
8.0.270.0030.00517.39
8.0.260.0050.00216.82
8.0.250.0050.00317.12
8.0.240.0040.00417.02
8.0.230.0000.00817.07
8.0.220.0040.00417.03
8.0.210.0000.00717.00
8.0.200.0030.00317.05
8.0.190.0040.00417.00
8.0.180.0040.00417.07
8.0.170.0030.00617.10
8.0.160.0030.00516.91
8.0.150.0040.00416.86
8.0.140.0050.00417.03
8.0.130.0060.00013.46
8.0.120.0000.00816.94
8.0.110.0050.00216.88
8.0.100.0080.00016.95
8.0.90.0050.00316.83
8.0.80.0040.01416.93
8.0.70.0040.00417.07
8.0.60.0000.00717.07
8.0.50.0070.00017.00
8.0.30.0080.01117.31
8.0.20.0110.01117.41
8.0.10.0040.00417.13
8.0.00.0180.00716.91
7.4.330.0000.00513.06
7.4.320.0070.00016.43
7.4.300.0000.00616.62
7.4.290.0000.00716.68
7.4.280.0090.00016.57
7.4.270.0000.00716.55
7.4.260.0000.00613.28
7.4.250.0080.00016.66
7.4.240.0040.00416.55
7.4.230.0030.00316.49
7.4.220.0060.01116.70
7.4.210.0080.01016.64
7.4.200.0040.00416.64
7.4.190.0040.00416.66
7.4.160.0100.00716.61
7.4.150.0130.00617.07
7.4.140.0110.00817.16
7.4.130.0120.00816.60
7.4.120.0090.00916.63
7.4.110.0030.01416.68
7.4.100.0000.02016.59
7.4.90.0120.00616.48
7.4.80.0070.01519.37
7.4.70.0100.01016.75
7.4.60.0090.01016.45
7.4.50.0110.00417.43
7.4.40.0100.00718.95
7.4.30.0080.01116.23
7.4.20.0120.00616.32
7.4.10.0110.01116.04
7.4.00.0110.00515.83
7.3.330.0030.00313.45
7.3.320.0000.00613.27
7.3.310.0040.00416.45
7.3.300.0000.00716.36
7.3.290.0030.01016.49
7.3.280.0080.00916.47
7.3.270.0160.01017.07
7.3.260.0090.01618.24
7.3.250.0120.00716.60
7.3.240.0130.00316.55
7.3.230.0100.01016.82
7.3.210.0100.00716.64
7.3.200.0120.00619.39
7.3.190.0080.01216.39
7.3.180.0110.01116.53
7.3.170.0090.00916.59
7.3.160.0130.01016.32
7.3.150.0040.01516.45
7.3.140.0080.00916.45
7.3.130.0130.00316.35
7.3.120.0090.01015.65
7.3.110.0080.01216.36
7.3.100.0130.01016.29
7.3.90.0110.01116.53
7.3.80.0140.00716.41
7.3.70.0100.00616.57
7.3.60.0100.00916.41
7.3.50.0040.02116.22
7.3.40.0130.00316.52
7.3.30.0060.01216.23
7.3.20.0060.01016.35
7.3.10.0130.00316.35
7.3.00.0090.01316.45
7.2.330.0120.00916.81
7.2.320.0130.00916.86
7.2.310.0180.00316.56
7.2.300.0100.00916.43
7.2.290.0090.00916.57
7.2.280.0090.00916.90
7.2.270.0130.00316.53
7.2.260.0100.00716.77
7.2.250.0090.01416.69
7.2.240.0160.00916.60
7.2.230.0160.00616.43
7.2.220.0100.01316.37
7.2.210.0070.01016.51
7.2.200.0170.00016.70
7.2.190.0090.00916.70
7.2.180.0030.01416.63
7.2.170.0030.01416.76
7.2.160.0100.01316.64
7.2.150.0130.00516.68
7.2.140.0180.00016.64
7.2.130.0110.00916.52
7.2.120.0040.01116.82
7.2.110.0070.01216.74
7.2.100.0080.01116.79
7.2.90.0080.01016.85
7.2.80.0110.00916.75
7.2.70.0190.00516.81
7.2.60.0120.00616.84
7.2.50.0100.00816.65
7.2.40.0080.01016.57
7.2.30.0060.01516.67
7.2.20.0080.01316.67
7.2.10.0070.01016.73
7.2.00.0090.00716.87
7.1.330.0040.01515.63
7.1.320.0080.01115.70
7.1.310.0090.00915.50
7.1.300.0070.01015.85
7.1.290.0090.00915.61
7.1.280.0140.00715.48
7.1.270.0140.00515.74
7.1.260.0090.00915.67
7.1.250.0050.01115.52
7.1.240.0130.00815.58
7.1.230.0050.01315.57
7.1.220.0100.00715.72
7.1.210.0120.00815.90
7.1.200.0170.00715.78
7.1.190.0080.01015.58
7.1.180.0090.01015.46
7.1.170.0100.01015.63
7.1.160.0110.00815.65
7.1.150.0230.01115.71
7.1.140.0120.00615.65
7.1.130.0110.00615.67
7.1.120.0140.00515.57
7.1.110.0120.00515.60
7.1.100.0150.00615.77
7.1.90.0050.01015.67
7.1.80.0070.00915.74
7.1.70.0070.00716.03
7.1.60.0130.00616.88
7.1.50.0190.00722.08
7.1.40.0120.00615.76
7.1.30.0080.01115.65
7.1.20.0110.00815.82
7.1.10.0100.00815.59
7.1.00.0080.03218.04
7.0.330.0060.01115.19
7.0.320.0100.00715.27
7.0.310.0100.00915.23
7.0.300.0060.01115.16
7.0.290.0070.01115.23
7.0.280.0070.01015.37
7.0.270.0040.01115.15
7.0.260.0060.01115.35
7.0.250.0080.00915.19
7.0.240.0080.00815.28
7.0.230.0060.01115.28
7.0.220.0110.00815.10
7.0.210.0100.00515.29
7.0.200.0070.00815.70
7.0.190.0080.00715.29
7.0.180.0090.00815.19
7.0.170.0100.00615.35
7.0.160.0170.00115.12
7.0.150.0070.00915.29
7.0.140.0080.03117.50
7.0.130.0160.00315.43
7.0.120.0050.01817.61
7.0.110.0120.02616.81
7.0.100.0120.03016.73
7.0.90.0070.03316.96
7.0.80.0070.03216.83
7.0.70.0150.02816.78
7.0.60.0090.02116.86
7.0.50.0090.02717.00
7.0.40.0060.02816.13
7.0.30.0130.02016.03
7.0.20.0090.03315.99
7.0.10.0080.02916.12
7.0.00.0030.03416.04
5.6.400.0200.00915.87
5.6.390.0140.00716.09
5.6.380.0050.01315.25
5.6.370.0090.00915.51
5.6.360.0120.01015.53
5.6.350.0070.01415.48
5.6.340.0050.01315.28
5.6.330.0100.00815.23
5.6.320.0100.01015.24
5.6.310.0070.00915.44
5.6.300.0080.01015.47
5.6.290.0080.00715.20
5.6.280.0080.02817.15
5.6.270.0110.01015.49
5.6.260.0110.03217.10
5.6.250.0110.03317.01
5.6.240.0080.02817.10
5.6.230.0110.03317.10
5.6.220.0060.02817.08
5.6.210.0110.03117.04
5.6.200.0040.03516.93
5.6.190.0100.02817.07
5.6.180.0070.02916.92
5.6.170.0040.02316.95
5.6.160.0080.03017.01
5.6.150.0090.03216.94
5.6.140.0090.02916.91
5.6.130.0100.03017.08
5.6.120.0080.03216.99
5.6.110.0090.03217.00
5.6.100.0100.03116.97
5.6.90.0100.03016.96
5.6.80.0070.03116.85
5.6.70.0120.01916.75
5.6.60.0120.02916.72
5.6.50.0110.02616.73
5.6.40.0060.03416.78
5.6.30.0120.03216.84
5.6.20.0120.02616.89
5.6.10.0090.02816.68
5.6.00.0120.02616.62
5.5.380.0090.02915.09
5.5.370.0090.03214.91
5.5.360.0060.03514.99
5.5.350.0100.03015.08
5.5.340.0070.03015.21
5.5.330.0070.03514.99
5.5.320.0060.02615.05
5.5.310.0070.02715.06
5.5.300.0090.02015.14
5.5.290.0090.02815.11
5.5.280.0070.03415.09
5.5.270.0080.02814.96
5.5.260.0090.02115.09
5.5.250.0100.02715.00
5.5.240.0060.03114.81
5.5.230.0040.03314.87
5.5.220.0060.02214.90
5.5.210.0130.02714.78
5.5.200.0070.02814.79
5.5.190.0080.02314.68
5.5.180.0070.03014.79
5.5.170.0130.00813.25
5.5.160.0020.03614.87
5.5.150.0090.02014.89
5.5.140.0070.03114.84
5.5.130.0050.02314.87
5.5.120.0090.02814.93
5.5.110.0060.02214.85
5.5.100.0090.03214.99
5.5.90.0100.02814.83
5.5.80.0100.02914.80
5.5.70.0040.03314.82
5.5.60.0110.02714.73
5.5.50.0070.03014.79
5.5.40.0130.02214.74
5.5.30.0060.03414.72
5.5.20.0060.03214.89
5.5.10.0100.02914.76
5.5.00.0070.03514.52
5.4.450.0050.03214.30
5.4.440.0070.03214.42
5.4.430.0070.03014.38
5.4.420.0070.03014.39
5.4.410.0100.02914.30
5.4.400.0030.03014.32
5.4.390.0110.02514.24
5.4.380.0070.03014.26
5.4.370.0070.02814.30
5.4.360.0080.02014.32
5.4.350.0050.02914.25
5.4.340.0060.01714.27
5.4.330.0030.00911.83
5.4.320.0040.02014.27
5.4.310.0060.02914.16
5.4.300.0040.03114.16
5.4.290.0050.02914.19
5.4.280.0080.02814.31
5.4.270.0090.02914.24
5.4.260.0040.03314.32
5.4.250.0070.02414.22
5.4.240.0090.02914.13
5.4.230.0130.02214.11
5.4.220.0130.02514.20
5.4.210.0100.02714.10
5.4.200.0090.03014.23
5.4.190.0040.03114.16
5.4.180.0090.02914.25
5.4.170.0070.02914.15
5.4.160.0030.03214.26
5.4.150.0060.03014.14
5.4.140.0050.02913.40
5.4.130.0130.02213.38
5.4.120.0070.03013.22
5.4.110.0060.02213.36
5.4.100.0070.02813.37
5.4.90.0120.02513.53
5.4.80.0060.02913.47
5.4.70.0060.02313.49
5.4.60.0090.02613.39
5.4.50.0070.02013.43
5.4.40.0120.02413.34
5.4.30.0120.02713.46
5.4.20.0100.02413.56
5.4.10.0090.02813.50
5.4.00.0100.02613.24
5.3.290.0060.02612.63
5.3.280.0060.02912.65
5.3.270.0040.03212.53
5.3.260.0020.03112.59
5.3.250.0100.02312.53
5.3.240.0060.02912.59
5.3.230.0070.03012.53
5.3.220.0030.02812.59
5.3.210.0090.02312.51
5.3.200.0060.02512.49
5.3.190.0070.02612.57
5.3.180.0050.02612.64
5.3.170.0060.02712.63
5.3.160.0040.02912.63
5.3.150.0040.03212.60
5.3.140.0080.02712.56
5.3.130.0030.03112.56
5.3.120.0090.02812.67
5.3.110.0030.03312.57
5.3.100.0100.02712.35
5.3.90.0070.02612.54
5.3.80.0110.02212.36
5.3.70.0060.02412.37
5.3.60.0040.01712.43
5.3.50.0070.02312.36
5.3.40.0040.01912.33
5.3.30.0020.01812.32
5.3.20.0040.01612.31
5.3.10.0040.01612.31
5.3.00.0050.01712.15
5.2.170.0030.01811.06
5.2.160.0060.01111.12
5.2.150.0040.01311.06
5.2.140.0080.01211.09
5.2.130.0030.01510.99
5.2.120.0050.02211.00
5.2.110.0030.01811.03
5.2.100.0020.01411.03
5.2.90.0060.01011.02
5.2.80.0050.01110.98
5.2.70.0020.01411.10
5.2.60.0040.01510.93
5.2.50.0040.01810.94
5.2.40.0020.01410.99
5.2.30.0050.01511.05
5.2.20.0020.01410.92
5.2.10.0050.01110.85
5.2.00.0010.01510.83
5.1.60.0050.00810.56
5.1.50.0050.01110.56
5.1.40.0020.01210.67
5.1.30.0020.01610.61
5.1.20.0030.01310.61
5.1.10.0040.01110.56
5.1.00.0040.01110.53
5.0.50.0000.01810.35
5.0.40.0030.00910.35
5.0.30.0030.01210.35
5.0.20.0010.01110.35
5.0.10.0030.00910.35
5.0.00.0030.01110.35
4.4.90.0020.00710.35
4.4.80.0020.00710.35
4.4.70.0020.00810.35
4.4.60.0020.00810.35
4.4.50.0030.00810.35
4.4.40.0040.00710.35
4.4.30.0020.01110.35
4.4.20.0020.00610.35
4.4.10.0020.01010.35
4.4.00.0020.01010.35
4.3.110.0020.00810.35
4.3.100.0000.00810.35
4.3.90.0010.00710.35
4.3.80.0020.01210.35
4.3.70.0020.00710.35
4.3.60.0020.00610.35
4.3.50.0020.00610.35
4.3.40.0060.00610.35
4.3.30.0030.00610.35
4.3.20.0030.01110.35
4.3.10.0020.00610.35
4.3.00.0020.00610.35

preferences:
47.39 ms | 401 KiB | 5 Q