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_contents(); $caughtOutput = $this->caughtOutput; ob_end_clean(); echo $this->caughtOutput = $caughtOutput; $caughtOutput = 0; // 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.70.0100.01316.75
8.3.60.0100.00718.55
8.3.50.0110.00421.95
8.3.40.0070.01118.80
8.3.30.0120.00919.19
8.3.20.0080.00020.34
8.3.10.0080.00023.54
8.3.00.0040.00419.26
8.2.180.0150.00418.29
8.2.170.0070.00722.96
8.2.160.0070.00720.52
8.2.150.0000.00824.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0000.00822.08
8.2.110.0040.00720.35
8.2.100.0120.00017.84
8.2.90.0000.00818.09
8.2.80.0030.00617.97
8.2.70.0080.00617.63
8.2.60.0050.00318.03
8.2.50.0060.00318.07
8.2.40.0030.00519.88
8.2.30.0000.00718.08
8.2.20.0080.00017.84
8.2.10.0000.00718.21
8.2.00.0000.00817.87
8.1.280.0110.00325.92
8.1.270.0020.00524.01
8.1.260.0050.00326.35
8.1.250.0080.00028.09
8.1.240.0090.00022.19
8.1.230.0080.00420.85
8.1.220.0000.00817.74
8.1.210.0000.00818.93
8.1.200.0030.00617.36
8.1.190.0000.00817.63
8.1.180.0040.00418.10
8.1.170.0000.00818.59
8.1.160.0030.00522.18
8.1.150.0070.00218.75
8.1.140.0000.00717.45
8.1.130.0030.00317.93
8.1.120.0070.00017.51
8.1.110.0040.00417.57
8.1.100.0030.00317.46
8.1.90.0080.00017.55
8.1.80.0000.00717.57
8.1.70.0030.00617.43
8.1.60.0080.00017.70
8.1.50.0080.00017.57
8.1.40.0000.00817.58
8.1.30.0000.00817.66
8.1.20.0050.00317.75
8.1.10.0070.00017.73
8.1.00.0040.00417.46
8.0.300.0080.00019.96
8.0.290.0070.00016.58
8.0.280.0040.00418.42
8.0.270.0040.00417.21
8.0.260.0000.00717.22
8.0.250.0000.00716.98
8.0.240.0040.00416.85
8.0.230.0000.00716.90
8.0.220.0040.00416.85
8.0.210.0000.00816.77
8.0.200.0060.00016.98
8.0.190.0050.00316.99
8.0.180.0030.00517.01
8.0.170.0000.00816.79
8.0.160.0000.00716.99
8.0.150.0030.00316.84
8.0.140.0000.00716.90
8.0.130.0060.00013.43
8.0.120.0000.00816.90
8.0.110.0040.00416.88
8.0.100.0040.00416.91
8.0.90.0070.00016.66
8.0.80.0140.00716.84
8.0.70.0040.00416.88
8.0.60.0050.00216.86
8.0.50.0050.00216.93
8.0.30.0150.01117.01
8.0.20.0080.01317.40
8.0.10.0070.00017.02
8.0.00.0160.01016.61
7.4.330.0030.00315.02
7.4.320.0050.00216.46
7.4.300.0040.00416.38
7.4.290.0030.00316.40
7.4.280.0070.00016.42
7.4.270.0000.00716.40
7.4.260.0040.00416.33
7.4.250.0030.00516.43
7.4.240.0030.00516.50
7.4.230.0040.00416.26
7.4.220.0160.00916.47
7.4.210.0090.00916.49
7.4.200.0000.00716.58
7.4.190.0050.00216.68
7.4.160.0160.00816.44
7.4.150.0140.00717.40
7.4.140.0110.01617.86
7.4.130.0120.00816.44
7.4.120.0100.01016.54
7.4.110.0090.00916.58
7.4.100.0160.01016.62
7.4.90.0150.00416.38
7.4.80.0090.01419.39
7.4.70.0120.01316.57
7.4.60.0100.00916.39
7.4.50.0090.00016.34
7.4.40.0140.00716.32
7.4.30.0090.00916.64
7.3.330.0031.99513.48
7.3.320.0031.99813.26
7.3.310.0040.00316.16
7.3.300.0000.00716.29
7.3.290.0040.01116.27
7.3.280.0110.00816.32
7.3.270.0160.00517.40
7.3.260.0120.00616.70
7.3.250.0100.01516.43
7.3.240.0150.00316.49
7.3.230.0180.00316.45
7.3.210.0090.01216.28
7.3.200.0080.01619.39
7.3.190.0090.01216.20
7.3.180.0030.01516.42
7.3.170.0110.00816.46
7.3.160.0030.01316.30
7.2.330.0120.00916.82
7.2.320.0080.01216.84
7.2.310.0100.01616.78
7.2.300.0170.00016.63
7.2.290.0100.01016.51
7.0.120.0000.04722.05
7.0.110.0030.04721.96
7.0.100.0030.05022.14
7.0.90.0000.03722.09
7.0.80.0000.04722.12
7.0.70.0000.06322.02
7.0.60.0000.06321.95
7.0.50.0100.06722.15
7.0.40.0100.03320.07
7.0.30.0070.03020.02
7.0.20.0030.05020.01
7.0.10.0030.06020.01
7.0.00.0000.08719.92
5.6.270.0070.03720.96
5.6.260.0100.03721.03
5.6.250.0070.04020.90
5.6.240.0030.04021.04
5.6.230.0070.04021.09
5.6.220.0000.07020.96
5.6.210.0070.07021.03
5.6.200.0000.08720.82
5.6.190.0030.04720.81
5.6.180.0030.05020.91
5.6.170.0030.05021.07
5.6.160.0070.04321.00
5.6.150.0030.04320.91
5.6.140.0130.03321.00
5.6.130.0070.04320.98
5.6.120.0070.04321.00
5.6.110.0070.07020.89
5.6.100.0070.04020.98
5.6.90.0030.06320.89
5.6.80.0070.06020.30
5.6.70.0070.06720.38
5.6.60.0070.07020.36
5.6.50.0130.05020.11
5.6.40.0000.04020.18
5.6.30.0030.07020.43
5.6.20.0000.07020.17
5.6.10.0000.04020.32
5.6.00.0000.04020.24
5.5.380.0100.04017.65
5.5.370.0030.04017.55
5.5.360.0000.07017.65
5.5.350.0000.04017.47
5.5.340.0000.04317.94
5.5.330.0000.04317.92
5.5.320.0000.04318.17
5.5.310.0000.04317.96
5.5.300.0000.04018.01
5.5.290.0030.04317.84
5.5.280.0070.06017.84
5.5.270.0030.04017.92
5.5.260.0030.05018.12
5.5.250.0070.06717.63
5.5.240.0000.04017.21
5.5.230.0030.04717.50
5.5.220.0000.04017.40
5.5.210.0000.07017.48
5.5.200.0000.04017.50
5.5.190.0100.03017.45
5.5.180.0030.05717.47
5.5.160.0030.03717.42
5.5.150.0100.07017.51
5.5.140.0000.04017.51
5.5.130.0000.05017.19
5.5.120.0030.05017.38
5.5.110.0100.03017.25
5.5.100.0070.05717.42
5.5.90.0030.05017.41
5.5.80.0000.03717.39
5.5.70.0000.04017.20
5.5.60.0000.04017.18
5.5.50.0000.04017.27
5.5.40.0030.04017.16
5.5.30.0030.03717.40
5.5.20.0070.05717.17
5.5.10.0030.08017.27
5.5.00.0000.06717.34
5.4.450.0070.04019.59
5.4.440.0030.04019.34
5.4.430.0030.05319.21
5.4.420.0030.07719.24
5.4.410.0070.04319.14
5.4.400.0070.07318.92
5.4.390.0070.04018.91
5.4.380.0070.05718.91
5.4.370.0000.03718.84
5.4.360.0070.05719.08
5.4.350.0000.04019.16
5.4.340.0030.03719.08
5.4.320.0030.03718.95
5.4.310.0030.06319.26
5.4.300.0070.07319.26
5.4.290.0030.04719.08
5.4.280.0000.06718.94
5.4.270.0000.05719.01
5.4.260.0070.07018.98
5.4.250.0030.05018.89
5.4.240.0070.06718.85
5.4.230.0030.04018.91
5.4.220.0030.07018.91
5.4.210.0000.03718.88
5.4.200.0000.06018.81
5.4.190.0100.03318.90
5.4.180.0030.07719.03
5.4.170.0030.05318.85
5.4.160.0000.06318.95
5.4.150.0070.03318.85
5.4.140.0030.04016.42
5.4.130.0000.03716.38
5.4.120.0100.06016.41
5.4.110.0000.03716.46
5.4.100.0070.04716.36
5.4.90.0030.03316.38
5.4.80.0030.03716.35
5.4.70.0000.03716.23
5.4.60.0000.03716.34
5.4.50.0030.04016.42
5.4.40.0000.03716.34
5.4.30.0070.06716.30
5.4.20.0000.03716.57
5.4.10.0000.05316.39
5.4.00.0000.03715.85
5.3.290.0030.03714.39
5.3.280.0030.07014.54
5.3.270.0000.04014.57
5.3.260.0000.06714.32
5.3.250.0030.06314.71
5.3.240.0030.04314.54
5.3.230.0030.03714.45
5.3.220.0000.04314.39
5.3.210.0030.06314.44
5.3.200.0000.07014.29
5.3.190.0130.03314.50
5.3.180.0000.03714.45
5.3.170.0030.04014.50
5.3.160.0000.03714.45
5.3.150.0030.04014.41
5.3.140.0000.04014.50
5.3.130.0030.03714.46
5.3.120.0000.04714.27
5.3.110.0000.03714.66
5.3.100.0000.05713.76
5.3.90.0030.04313.88
5.3.80.0000.04313.89
5.3.70.0030.03713.79
5.3.60.0070.05313.66
5.3.50.0100.07313.76
5.3.40.0000.04313.75
5.3.30.0000.04313.68
5.3.20.0000.03313.57
5.3.10.0100.05713.45
5.3.00.0030.05713.43
5.2.170.0000.03711.64
5.2.160.0000.03711.64
5.2.150.0030.02711.64
5.2.140.0030.03011.64
5.2.130.0030.02311.64
5.2.120.0000.03311.64
5.2.110.0030.03711.64
5.2.100.0000.04311.64
5.2.90.0030.02711.64
5.2.80.0000.06311.64
5.2.70.0030.05711.64
5.2.60.0030.02711.64
5.2.50.0000.05311.64
5.2.40.0000.03011.64
5.2.30.0000.02711.64
5.2.20.0000.02711.64
5.2.10.0070.03011.64
5.2.00.0030.03311.64
5.1.60.0000.02711.64
5.1.50.0000.03311.64
5.1.40.0000.02311.64
5.1.30.0000.03011.64
5.1.20.0000.02711.64
5.1.10.0000.02311.64
5.1.00.0000.02311.64
5.0.50.0000.02011.64
5.0.40.0030.01711.64
5.0.30.0000.03311.64
5.0.20.0000.02011.64
5.0.10.0030.01711.64
5.0.00.0000.02711.64
4.4.90.0000.01311.64
4.4.80.0000.01311.64
4.4.70.0070.02711.64
4.4.60.0030.01711.64
4.4.50.0000.01311.64
4.4.40.0000.02711.64
4.4.30.0030.01011.64
4.4.20.0000.01311.64
4.4.10.0000.01311.64
4.4.00.0000.02711.64
4.3.110.0000.01311.64
4.3.100.0000.01011.64
4.3.90.0000.01011.64
4.3.80.0000.02011.64
4.3.70.0000.01311.64
4.3.60.0000.01311.64
4.3.50.0030.01011.64
4.3.40.0000.02311.64
4.3.30.0000.01311.64
4.3.20.0000.01311.64
4.3.10.0000.01311.64
4.3.00.0000.01311.64

preferences:
36.91 ms | 401 KiB | 5 Q