3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Symfony\Component\Debug; if (!defined('ENT_SUBSTITUTE')) { define('ENT_SUBSTITUTE', 8); } class ExceptionHandler { private $debug; private $charset; private $handler; private $caughtOutput = 0; public function __construct($debug = true, $charset = 'UTF-8') { $this->debug = $debug; $this->charset = $charset; } public static function register($debug = true) { $handler = new static($debug); set_exception_handler(array($handler, 'handle')); return $handler; } public function setHandler($handler) { if (isset($handler) && !is_callable($handler)) { throw new \LogicException('The exception handler must be a valid PHP callable.'); } $old = $this->handler; $this->handler = $handler; return $old; } public function handle(\Exception $exception) { $caughtOutput = 0; $this->caughtOutput = false; ob_start(array($this, 'catchOutput')); echo $exception->getMessage(); while (false === $this->caughtOutput) { ob_get_clean(); // Empty loop, everything is in the condition } if (isset($this->caughtOutput[0])) { ob_start(array($this, 'cleanOutput')); echo $this->caughtOutput; $caughtOutput = ob_get_length(); } $this->caughtOutput = 0; if (!empty($this->handler)) { try { call_user_func($this->handler, $exception); if ($caughtOutput) { $this->caughtOutput = $caughtOutput; } ob_end_flush(); } catch (\Exception $e) { if (!$caughtOutput) { // All handlers failed. Let PHP handle that now. throw $exception; } } } } public function catchOutput($buffer) { $this->caughtOutput = $buffer; return ''; } public function cleanOutput($buffer) { if ($this->caughtOutput) { // use substr_replace() instead of substr() for mbstring overloading resistance $cleanBuffer = substr_replace($buffer, '', 0, $this->caughtOutput); if (isset($cleanBuffer[0])) { $buffer = $cleanBuffer; } } return $buffer; } } ExceptionHandler::register(); throw new \Exception('foo msg');

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.00916.63
8.3.50.0130.00522.07
8.3.40.0100.01018.96
8.3.30.0060.01219.22
8.3.20.0040.00420.34
8.3.10.0090.00023.68
8.3.00.0040.00419.50
8.2.180.0070.01118.29
8.2.170.0040.01122.96
8.2.160.0130.00720.35
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0050.00322.21
8.2.110.0030.00619.39
8.2.100.0120.00018.03
8.2.90.0060.00319.21
8.2.80.0030.00517.97
8.2.70.0030.00617.75
8.2.60.0030.00618.04
8.2.50.0030.00618.07
8.2.40.0090.00019.88
8.2.30.0020.00518.10
8.2.20.0040.00417.94
8.2.10.0000.00818.20
8.2.00.0050.00317.69
8.1.280.0070.00725.92
8.1.270.0040.00423.92
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0040.00421.43
8.1.230.0070.00417.42
8.1.220.0000.00817.74
8.1.210.0050.00318.77
8.1.200.0040.00417.36
8.1.190.0060.00317.35
8.1.180.0000.00918.10
8.1.170.0040.00418.50
8.1.160.0000.00721.95
8.1.150.0090.00018.57
8.1.140.0020.00517.34
8.1.130.0000.00717.78
8.1.120.0070.00017.48
8.1.110.0040.00417.37
8.1.100.0040.00417.49
8.1.90.0000.00817.46
8.1.80.0020.00517.49
8.1.70.0000.00817.37
8.1.60.0030.00517.64
8.1.50.0000.00817.54
8.1.40.0050.00217.45
8.1.30.0050.00317.67
8.1.20.0040.00417.57
8.1.10.0000.00817.47
8.1.00.0040.00417.54
8.0.300.0020.00518.77
8.0.290.0000.00916.88
8.0.280.0040.00418.46
8.0.270.0030.00317.25
8.0.260.0030.00317.34
8.0.250.0000.00717.07
8.0.240.0030.00317.03
8.0.230.0000.00717.07
8.0.220.0030.00316.89
8.0.210.0000.00716.98
8.0.200.0000.00816.92
8.0.190.0000.00816.93
8.0.180.0040.00417.01
8.0.170.0030.00517.02
8.0.160.0000.00717.00
8.0.150.0040.00416.98
8.0.140.0050.00216.98
8.0.130.0060.00013.39
8.0.120.0000.00816.82
8.0.110.0040.00416.90
8.0.100.0040.00416.95
8.0.90.0040.00416.87
8.0.80.0060.00916.96
8.0.70.0000.00717.04
8.0.60.0050.00216.93
8.0.50.0050.00316.99
8.0.30.0090.00917.06
8.0.20.0130.00617.40
8.0.10.0040.00417.09
8.0.00.0090.00816.75
7.4.330.0000.00515.00
7.4.320.0040.00416.50
7.4.300.0030.00316.54
7.4.290.0000.00716.45
7.4.280.0080.00016.52
7.4.270.0040.00416.61
7.4.260.0070.00016.50
7.4.250.0070.00016.48
7.4.240.0000.00716.50
7.4.230.0040.00416.61
7.4.220.0180.00016.66
7.4.210.0080.00716.62
7.4.200.0070.00016.69
7.4.190.0000.00716.68
7.4.160.0130.00316.73
7.4.150.0060.01217.40
7.4.140.0100.01017.86
7.4.130.0100.00716.55
7.4.120.0070.01016.50
7.4.110.0030.01316.68
7.4.100.0180.00616.49
7.4.90.0030.01316.63
7.4.80.0160.00419.39
7.4.70.0070.01016.61
7.4.60.0030.01216.49
7.4.50.0060.00316.49
7.4.40.0110.00716.49
7.4.30.0070.01016.70
7.4.00.0040.01415.21
7.3.330.0030.00313.22
7.3.320.0000.00513.41
7.3.310.0000.00716.26
7.3.300.0070.00016.44
7.3.290.0130.00716.39
7.3.280.0100.00616.37
7.3.270.0070.01017.40
7.3.260.0210.00416.52
7.3.250.0080.01116.51
7.3.240.0140.00416.42
7.3.230.0140.00316.55
7.3.210.0060.01016.37
7.3.200.0040.01519.39
7.3.190.0090.01216.44
7.3.180.0060.00916.49
7.3.170.0110.00616.52
7.3.160.0050.01016.47
7.3.120.0030.01315.02
7.2.330.0060.01616.57
7.2.320.0000.01616.82
7.2.310.0070.01016.84
7.2.300.0130.00316.78
7.2.290.0140.00416.79
7.2.60.0190.00016.42
7.1.200.0040.00715.91
7.1.70.0040.00417.17
7.1.60.0030.00919.46
7.1.50.0100.01716.58
7.1.00.0000.08022.31
7.0.200.0070.02216.58
7.0.140.0000.07721.95
7.0.110.0100.08020.00
7.0.100.0100.07320.13
7.0.90.0030.08020.10
7.0.80.0030.08719.91
7.0.70.0100.08019.89
7.0.60.0030.04719.94
7.0.50.0130.03019.99
7.0.40.0100.07319.75
7.0.30.0030.06319.70
7.0.20.0030.05719.84
7.0.10.0100.05019.66
7.0.00.0070.07719.73
5.6.280.0000.08021.01
5.6.260.0100.04720.77
5.6.250.0100.08020.69
5.6.240.0030.08320.50
5.6.230.0100.07720.59
5.6.220.0000.08320.58
5.6.210.0070.04720.83
5.6.200.0100.04320.58
5.6.190.0170.04320.62
5.6.180.0030.06720.61
5.6.170.0070.08020.67
5.6.160.0000.08720.57
5.6.150.0030.05020.65
5.6.140.0030.08320.57
5.6.130.0030.08020.64
5.6.120.0130.07020.72
5.6.110.0100.04320.47
5.6.100.0030.05020.70
5.6.90.0000.04320.61
5.6.80.0100.06019.96
5.6.70.0100.04020.24
5.6.60.0100.04320.07
5.6.50.0170.07319.97
5.6.40.0000.06719.91
5.6.30.0070.04019.93
5.6.20.0070.05319.93
5.6.10.0170.06320.00
5.6.00.0030.08320.05
5.5.380.0130.07317.54
5.5.370.0130.04017.71
5.5.360.0170.04317.70
5.5.350.0100.06717.63
5.5.340.0000.05317.93
5.5.330.0170.04318.13
5.5.320.0070.07718.10
5.5.310.0200.07718.10
5.5.300.0030.08317.93
5.5.290.0070.07717.91
5.5.280.0070.08318.04
5.5.270.0070.04317.91
5.5.260.0070.04317.92
5.5.250.0130.03718.04
5.5.240.0000.07717.63
5.5.230.0030.05317.47
5.5.220.0070.06017.30
5.5.210.0170.06317.47
5.5.200.0100.06717.58
5.5.190.0030.05017.45
5.5.180.0030.04017.58
5.5.160.0170.08317.27
5.5.150.0070.05317.41
5.5.140.0070.04717.47
5.5.130.0030.04317.26
5.5.120.0100.07717.39
5.5.110.0070.08317.28
5.5.100.0070.07717.09
5.5.90.0000.08717.48
5.5.80.0070.04317.39
5.5.70.0100.04017.34
5.5.60.0070.07717.49
5.5.50.0070.05317.39
5.5.40.0100.05017.51
5.5.30.0130.07317.15
5.5.20.0030.07017.14
5.5.10.0170.06717.46
5.5.00.0030.05717.30
5.4.450.0030.06019.47
5.4.440.0100.03719.66
5.4.430.0100.04019.46
5.4.420.0000.05719.33
5.4.410.0130.07319.21
5.4.400.0130.03319.18
5.4.390.0030.04019.02
5.4.380.0070.04318.99
5.4.370.0030.06019.02
5.4.360.0030.07319.18
5.4.350.0070.07319.18
5.4.340.0100.06318.98
5.4.320.0030.04319.16
5.4.310.0000.05319.18
5.4.300.0030.03719.31
5.4.290.0070.05719.18
5.4.280.0070.06318.93
5.4.270.0070.04019.00
5.4.260.0070.04019.17
5.4.250.0030.05018.98
5.4.240.0100.05719.02
5.4.230.0030.04018.96
5.4.220.0130.03319.13
5.4.210.0130.07319.00
5.4.200.0100.08019.03
5.4.190.0100.06718.93
5.4.180.0070.04319.01
5.4.170.0070.03718.97
5.4.160.0100.06719.00
5.4.150.0070.03719.14
5.4.140.0070.07016.45
5.4.130.0070.05716.39
5.4.120.0100.03016.45
5.4.110.0030.07016.57
5.4.100.0070.07716.55
5.4.90.0130.06316.65
5.4.80.0030.07316.44
5.4.70.0100.03316.45
5.4.60.0100.05316.25
5.4.50.0070.03716.51
5.4.40.0000.07716.39
5.4.30.0130.06016.42
5.4.20.0100.05316.29
5.4.10.0100.04716.56
5.4.00.0030.03715.75
5.3.290.0070.03714.73
5.3.280.0100.07314.70
5.3.270.0070.04314.70
5.3.260.0030.04314.70
5.3.250.0070.05314.76
5.3.240.0130.07014.86
5.3.230.0000.04314.70
5.3.220.0100.06014.70
5.3.210.0030.07314.70
5.3.200.0100.07014.70
5.3.190.0030.08314.70
5.3.180.0130.06314.70
5.3.170.0070.05314.70
5.3.160.0030.07014.70
5.3.150.0100.08714.70
5.3.140.0000.04314.70
5.3.130.0030.05014.70
5.3.120.0100.06314.70
5.3.110.0070.06714.70
5.3.100.0100.06314.70
5.3.90.0000.04314.70
5.3.80.0000.06714.70
5.3.70.0100.07014.70
5.3.60.0030.07314.70
5.3.50.0100.07014.70
5.3.40.0130.07014.70
5.3.30.0070.06314.70
5.3.20.0100.07314.70
5.3.10.0070.04314.70
5.3.00.0070.07014.70
5.2.170.0070.06014.70
5.2.160.0070.05314.70
5.2.150.0000.03714.70
5.2.140.0100.02714.70
5.2.130.0100.05714.70
5.2.120.0000.06714.70
5.2.110.0000.03714.70
5.2.100.0030.06714.70
5.2.90.0000.06714.70
5.2.80.0070.05714.70
5.2.70.0100.04314.70
5.2.60.0030.06314.70
5.2.50.0030.05314.70
5.2.40.0070.05014.70
5.2.30.0070.06014.70
5.2.20.0070.04714.70
5.2.10.0100.04714.70
5.2.00.0030.04014.70
5.1.60.0000.05314.70
5.1.50.0030.04014.70
5.1.40.0070.04714.70
5.1.30.0030.04714.70
5.1.20.0100.05014.70
5.1.10.0030.05014.70
5.1.00.0100.05014.70
5.0.50.0070.03714.70
5.0.40.0030.04314.70
5.0.30.0070.05714.70
5.0.20.0030.04314.70
5.0.10.0000.04314.70
5.0.00.0000.05314.70
4.4.90.0030.03014.70
4.4.80.0030.03014.70
4.4.70.0070.03314.70
4.4.60.0030.03714.70
4.4.50.0000.03314.70
4.4.40.0000.05714.70
4.4.30.0070.01314.70
4.4.20.0030.02314.70
4.4.10.0000.03314.70
4.4.00.0000.04714.70
4.3.110.0100.03314.70
4.3.100.0070.03014.70
4.3.90.0030.02714.70
4.3.80.0000.05314.70
4.3.70.0070.02714.70
4.3.60.0030.02014.70
4.3.50.0070.03014.70
4.3.40.0000.03014.70
4.3.30.0030.02314.70
4.3.20.0000.02314.70
4.3.10.0000.02314.70
4.3.00.0030.03314.70

preferences:
51.68 ms | 401 KiB | 5 Q