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(); if (false === $this->caughtOutput) { ob_end_clean(); echo 234; } 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.0070.01416.88
8.3.50.0110.00522.00
8.3.40.0090.00618.97
8.3.30.0070.00719.26
8.3.20.0050.00320.13
8.3.10.0000.00823.66
8.3.00.0040.00419.38
8.2.180.0090.00916.75
8.2.170.0100.01022.96
8.2.160.0110.00720.43
8.2.150.0160.00324.18
8.2.140.0040.00424.66
8.2.130.0060.00326.16
8.2.120.0040.00422.27
8.2.110.0070.00319.38
8.2.100.0000.01118.03
8.2.90.0000.00819.25
8.2.80.0000.00817.97
8.2.70.0060.00317.63
8.2.60.0040.00417.88
8.2.50.0060.00318.07
8.2.40.0060.00320.01
8.2.30.0040.00418.14
8.2.20.0000.00817.89
8.2.10.0040.00418.14
8.2.00.0070.00317.75
8.1.280.0110.00425.92
8.1.270.0040.00423.82
8.1.260.0080.00026.35
8.1.250.0040.00428.09
8.1.240.0000.00921.37
8.1.230.0060.00617.52
8.1.220.0040.00417.79
8.1.210.0030.00618.77
8.1.200.0050.00517.35
8.1.190.0040.00417.35
8.1.180.0050.00318.10
8.1.170.0040.00418.59
8.1.160.0040.00421.93
8.1.150.0060.00618.66
8.1.140.0040.00417.51
8.1.130.0000.00717.72
8.1.120.0030.00317.39
8.1.110.0030.00617.44
8.1.100.0000.00717.38
8.1.90.0040.00417.55
8.1.80.0040.00417.46
8.1.70.0000.00717.40
8.1.60.0080.00017.59
8.1.50.0000.00817.54
8.1.40.0030.00517.46
8.1.30.0040.00417.66
8.1.20.0000.00817.71
8.1.10.0000.00817.49
8.1.00.0000.00817.42
8.0.300.0050.00318.77
8.0.290.0000.00716.75
8.0.280.0030.00318.54
8.0.270.0070.00017.20
8.0.260.0000.00817.19
8.0.250.0030.00417.04
8.0.240.0040.00417.01
8.0.230.0040.00316.91
8.0.220.0000.00716.89
8.0.210.0050.00216.98
8.0.200.0030.00317.05
8.0.190.0060.00317.05
8.0.180.0050.00316.89
8.0.170.0050.00317.04
8.0.160.0000.00716.86
8.0.150.0000.00716.88
8.0.140.0000.00716.95
8.0.130.0000.00613.41
8.0.120.0000.00816.97
8.0.110.0000.00716.97
8.0.100.0040.00416.86
8.0.90.0080.00016.86
8.0.80.0090.00916.90
8.0.70.0040.00416.87
8.0.60.0030.00516.98
8.0.50.0050.00217.04
8.0.30.0050.01517.21
8.0.20.0140.00517.40
8.0.10.0040.00417.08
8.0.00.0150.00516.72
7.4.330.0050.00015.09
7.4.320.0050.00316.63
7.4.300.0060.00016.47
7.4.290.0030.00316.60
7.4.280.0000.00716.53
7.4.270.0040.00416.64
7.4.260.0020.00516.57
7.4.250.0000.00716.50
7.4.240.0030.00416.58
7.4.230.0000.00716.64
7.4.220.0100.00716.66
7.4.210.0100.00916.57
7.4.200.0040.00416.69
7.4.190.0000.00816.71
7.4.160.0180.00616.46
7.4.150.0120.00617.40
7.4.140.0080.01217.86
7.4.130.0110.00816.45
7.4.120.0130.00316.63
7.4.110.0120.00816.44
7.4.100.0030.01516.60
7.4.90.0090.00916.39
7.4.80.0060.01219.39
7.4.70.0030.01316.75
7.4.60.0000.01716.40
7.4.50.0040.00416.42
7.4.40.0090.01516.61
7.4.30.0070.01016.65
7.4.00.0060.00614.95
7.3.330.0060.00013.26
7.3.320.0000.00513.20
7.3.310.0000.00716.49
7.3.300.0000.00716.25
7.3.290.0030.01016.53
7.3.280.0100.00816.36
7.3.270.0120.00617.40
7.3.260.0130.00616.47
7.3.250.0090.00916.45
7.3.240.0110.00816.66
7.3.230.0100.00716.43
7.3.210.0000.01716.42
7.3.200.0070.01119.39
7.3.190.0130.00616.57
7.3.180.0120.00616.47
7.3.170.0150.00616.57
7.3.160.0030.01716.43
7.3.120.0060.00614.91
7.2.330.0090.00916.56
7.2.320.0100.01016.88
7.2.310.0100.01316.57
7.2.300.0060.01216.69
7.2.290.0060.01716.65
7.2.60.0100.00316.76
7.2.00.0030.00919.43
7.1.100.0110.00417.86
7.1.70.0030.00916.95
7.1.60.0060.01919.46
7.1.50.0070.01516.72
7.1.00.0030.07722.58
7.0.200.0000.01016.88
7.0.140.0170.06022.12
7.0.60.0030.08319.84
7.0.50.0030.08017.91
7.0.40.0000.05019.96
7.0.30.0270.06020.24
7.0.20.0330.08020.16
7.0.10.0130.06720.08
7.0.00.0170.06020.26
5.6.280.0070.07021.12
5.6.210.0070.08320.49
5.6.200.0030.04018.18
5.6.190.0100.05720.68
5.6.180.0030.05020.61
5.6.170.0230.04020.51
5.6.160.0100.08320.70
5.6.150.0030.04018.19
5.6.140.0100.06718.24
5.6.130.0070.04718.18
5.6.120.0130.06021.17
5.6.110.0000.04320.96
5.6.100.0130.07721.04
5.6.90.0070.04020.99
5.6.80.0030.04320.55
5.5.350.4130.04320.39
5.5.340.0130.04317.99
5.5.330.0100.06720.43
5.5.320.0270.08020.20
5.5.310.0400.07320.34
5.5.300.0130.07017.96
5.5.290.0030.09018.07
5.5.280.0070.05320.76
5.5.270.0130.08721.00
5.5.260.0000.04320.84
5.5.250.0230.06720.45
5.5.240.0000.08320.18
5.4.450.0170.06319.58
5.4.440.0200.07019.47
5.4.430.0130.06019.57
5.4.420.0170.05719.47
5.4.410.0170.05319.45
5.4.400.0100.05719.23
5.4.390.0200.05019.29
5.4.380.0130.06018.84
5.4.370.0100.06018.73
5.4.360.0070.06018.80
5.4.350.0230.04318.58
5.4.340.0130.05318.72
5.4.320.0040.03912.52
5.4.310.0110.03212.52
5.4.300.0060.03812.52
5.4.290.0040.04112.51
5.4.280.0060.04512.41
5.4.270.0060.03912.41
5.4.260.0090.05212.41
5.4.250.0120.05212.41
5.4.240.0070.05412.41
5.4.230.0100.05112.41
5.4.220.0160.08512.40
5.4.210.0070.05512.40
5.4.200.0130.05312.41
5.4.190.0060.05412.40
5.4.180.0110.04712.39
5.4.170.0120.05012.41
5.4.160.0080.05312.41
5.4.150.0100.04712.40
5.4.140.0180.04612.08
5.4.130.0160.04712.07
5.4.120.0130.05112.04
5.4.110.0110.04612.03
5.4.100.0080.04512.02
5.4.90.0070.05612.03
5.4.80.0100.05512.03
5.4.70.0100.05112.02
5.4.60.0100.05212.02
5.4.50.0080.05212.03
5.4.40.0100.05112.02
5.4.30.0110.04812.01
5.4.20.0090.05212.01
5.4.10.0060.05012.01
5.4.00.0070.05011.50
5.3.290.0090.04312.80
5.3.280.0070.05012.71
5.3.270.0100.05212.73
5.3.260.0120.05012.73
5.3.250.0100.05012.73
5.3.240.0140.07912.73
5.3.230.0080.05412.72
5.3.220.0060.05912.70
5.3.210.0130.06412.70
5.3.200.0130.05912.70
5.3.190.0090.05612.69
5.3.180.0100.05512.69
5.3.170.0060.05612.69
5.3.160.0060.05812.69
5.3.150.0210.09812.70
5.3.140.0270.08412.68
5.3.130.0220.06412.67
5.3.120.0120.05912.68
5.3.110.0200.11412.67
5.3.100.0080.06012.16
5.3.90.0100.04812.14
5.3.80.0080.04812.14
5.3.70.0080.04612.14
5.3.60.0070.05112.12
5.3.50.0110.04912.06
5.3.40.0080.05112.06
5.3.30.0100.04712.02
5.3.20.0130.05811.80
5.3.10.0100.06011.77
5.3.00.0160.09411.76
5.2.170.0060.0539.19
5.2.160.0180.0539.19
5.2.150.0140.0529.18
5.2.140.0080.0489.18
5.2.130.0060.0489.14
5.2.120.0050.0499.14
5.2.110.0060.0479.16
5.2.100.0080.0469.15
5.2.90.0060.0489.14
5.2.80.0100.0539.14
5.2.70.0040.0519.14
5.2.60.0090.0459.10
5.2.50.0080.0459.07
5.2.40.0090.0409.04
5.2.30.0060.0489.01
5.2.20.0060.0459.01
5.2.10.0080.0438.93
5.2.00.0050.0538.79
5.1.60.0140.0448.07
5.1.50.0120.0348.06
5.1.40.0130.0328.05
5.1.30.0060.0438.40
5.1.20.0060.0448.42
5.1.10.0090.0388.14
5.1.00.0060.0378.15
5.0.50.0020.0346.62
5.0.40.0060.0336.48
5.0.30.0060.0526.29
5.0.20.0050.0316.27
5.0.10.0100.0286.25
5.0.00.0050.0476.23
4.4.90.0050.0244.78
4.4.80.0040.0244.75
4.4.70.0070.0344.76
4.4.60.0050.0214.75
4.4.50.0010.0244.77
4.4.40.0060.0374.71
4.4.30.0060.0204.75
4.4.20.0050.0254.84
4.4.10.0040.0284.84
4.4.00.0080.0374.76
4.3.110.0070.0234.67
4.3.100.0060.0284.67
4.3.90.0050.0454.64
4.3.80.0110.0344.59
4.3.70.0070.0244.63
4.3.60.0030.0294.63
4.3.50.0050.0264.63
4.3.40.0080.0354.54
4.3.30.0030.0283.29
4.3.20.0040.0273.26
4.3.10.0040.0293.22
4.3.00.0030.0207.52

preferences:
36.38 ms | 401 KiB | 5 Q