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_end_flush()) { // 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.0070.01016.75
8.3.50.0100.00522.00
8.3.40.0120.00318.92
8.3.30.0170.00319.04
8.3.20.0000.00720.21
8.3.10.0050.00523.66
8.3.00.0040.00419.25
8.2.180.0130.00716.38
8.2.170.0120.00322.96
8.2.160.0130.00020.53
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0000.00826.16
8.2.120.0000.00822.25
8.2.110.0060.00320.93
8.2.100.0040.00718.03
8.2.90.0040.00418.95
8.2.80.0030.00617.97
8.2.70.0000.00817.63
8.2.60.0040.00418.03
8.2.50.0030.00518.10
8.2.40.0050.00320.59
8.2.30.0000.00919.91
8.2.20.0040.00417.79
8.2.10.0060.00318.13
8.2.00.0040.00417.74
8.1.280.0150.00025.92
8.1.270.0040.00424.00
8.1.260.0050.00326.35
8.1.250.0070.00028.09
8.1.240.0050.00520.96
8.1.230.0040.00717.89
8.1.220.0000.00917.76
8.1.210.0040.00418.77
8.1.200.0030.00617.13
8.1.190.0050.00317.22
8.1.180.0060.00318.10
8.1.170.0040.00418.56
8.1.160.0000.00722.10
8.1.150.0030.00618.65
8.1.140.0050.00317.48
8.1.130.0000.00717.85
8.1.120.0000.00717.38
8.1.110.0040.00417.47
8.1.100.0070.00017.38
8.1.90.0050.00217.43
8.1.80.0030.00617.39
8.1.70.0070.00017.45
8.1.60.0030.00617.48
8.1.50.0060.00317.54
8.1.40.0040.00417.42
8.1.30.0000.00817.69
8.1.20.0050.00317.50
8.1.10.0030.00617.63
8.1.00.0030.00517.46
8.0.300.0040.00418.77
8.0.290.0050.00216.75
8.0.280.0070.00018.34
8.0.270.0000.00717.19
8.0.260.0000.00617.28
8.0.250.0000.00716.96
8.0.240.0060.00017.00
8.0.230.0070.00016.93
8.0.220.0000.00716.93
8.0.210.0030.00316.99
8.0.200.0040.00417.03
8.0.190.0050.00317.10
8.0.180.0070.00016.90
8.0.170.0040.00416.92
8.0.160.0000.00816.97
8.0.150.0070.00016.91
8.0.140.0040.00416.93
8.0.130.0030.00313.41
8.0.120.0000.00816.83
8.0.110.0000.00817.00
8.0.100.0000.00716.85
8.0.90.0060.00316.95
8.0.80.0130.01016.93
8.0.70.0040.00416.85
8.0.60.0070.00016.92
8.0.50.0000.00717.00
8.0.30.0120.01017.07
8.0.20.0060.01317.40
8.0.10.0040.00417.08
8.0.00.0100.00916.82
7.4.330.0050.00015.06
7.4.320.0000.00716.60
7.4.300.0060.00016.63
7.4.290.0030.00316.45
7.4.280.0050.00316.66
7.4.270.0030.00516.66
7.4.260.0070.00016.62
7.4.250.0000.00816.59
7.4.240.0020.00516.44
7.4.230.0070.00016.54
7.4.220.0030.01416.64
7.4.210.0080.00916.56
7.4.200.0040.00416.66
7.4.190.0080.00016.75
7.4.160.0030.01316.67
7.4.150.0060.01217.40
7.4.140.0120.00717.86
7.4.130.0070.01216.54
7.4.120.0100.00916.46
7.4.110.0090.00916.35
7.4.100.0110.00716.61
7.4.90.0110.00616.59
7.4.80.0100.00719.39
7.4.70.0110.00716.63
7.4.60.0080.00816.43
7.4.50.0000.00916.75
7.4.40.0100.01016.69
7.4.30.0110.00516.65
7.4.10.0060.00814.80
7.4.00.0080.01014.99
7.3.330.0050.00213.39
7.3.320.0060.00013.39
7.3.310.0000.00816.41
7.3.300.0040.00416.34
7.3.290.0100.00616.38
7.3.280.0100.00816.41
7.3.270.0100.00717.40
7.3.260.0120.00916.43
7.3.250.0130.00816.61
7.3.240.0070.01316.64
7.3.230.0110.00616.63
7.3.210.0100.01016.55
7.3.200.0090.01319.39
7.3.190.0090.00916.50
7.3.180.0110.01116.62
7.3.170.0100.00716.49
7.3.160.0100.00616.64
7.3.130.0040.01114.99
7.3.120.0100.00615.01
7.3.110.0090.00914.77
7.3.100.0080.00414.89
7.3.90.0090.00914.92
7.3.80.0030.01014.83
7.3.70.0000.00814.70
7.3.60.0040.01115.00
7.3.50.0060.00914.98
7.3.40.0110.00414.81
7.3.30.0090.00014.87
7.3.20.0000.01216.59
7.3.10.0080.00816.79
7.3.00.0040.01216.82
7.2.330.0070.01316.91
7.2.320.0030.01716.82
7.2.310.0100.01016.77
7.2.300.0030.01316.78
7.2.290.0030.01416.65
7.2.260.0110.00715.36
7.2.250.0100.00315.13
7.2.240.0110.00414.79
7.2.230.0090.00615.41
7.2.220.0130.00314.79
7.2.210.0030.01015.10
7.2.200.0120.00315.24
7.2.190.0030.01215.12
7.2.180.0040.00815.20
7.2.170.0060.00915.26
7.2.160.0080.00414.79
7.2.150.0040.01116.67
7.2.140.0030.00717.11
7.2.130.0130.00317.07
7.2.120.0040.00717.01
7.2.110.0140.00316.58
7.2.100.0090.00617.09
7.2.90.0060.01216.99
7.2.80.0030.01417.12
7.2.70.0000.01616.97
7.2.60.0060.00617.12
7.2.50.0080.00816.98
7.2.40.0060.00916.77
7.2.30.0100.00717.00
7.2.20.0000.01116.97
7.2.10.0030.01017.04
7.2.00.0030.01018.07
7.1.330.0070.00715.94
7.1.320.0100.00715.80
7.1.310.0000.01015.87
7.1.300.0030.00715.67
7.1.290.0060.00915.51
7.1.280.0030.01015.79
7.1.270.0120.00315.73
7.1.260.0030.00915.54
7.1.250.0000.01315.86
7.1.240.0110.00415.90
7.1.230.0070.00415.61
7.1.220.0070.01015.48
7.1.210.0030.01215.55
7.1.200.0100.00715.92
7.1.190.0040.01215.47
7.1.180.0000.00815.73
7.1.170.0040.01115.94
7.1.160.0040.01215.72
7.1.150.0060.00615.62
7.1.140.0050.00515.46
7.1.130.0050.00515.90
7.1.120.0090.00615.88
7.1.110.0070.00415.81
7.1.100.0050.00717.03
7.1.90.0090.00615.72
7.1.80.0100.00315.85
7.1.70.0040.00916.47
7.1.60.0050.00817.58
7.1.50.0090.00916.23
7.1.40.0090.00615.78
7.1.30.0090.00615.73
7.1.20.0030.01015.77
7.1.10.0070.00715.55
7.1.00.0050.04219.01
7.0.330.0040.00415.40
7.0.320.0030.01015.43
7.0.310.0060.00915.46
7.0.300.0090.00615.44
7.0.290.0070.00715.61
7.0.280.0070.00715.20
7.0.270.0040.01115.45
7.0.260.0030.00515.25
7.0.250.0030.00915.51
7.0.240.0060.00915.49
7.0.230.0110.00315.43
7.0.220.0070.00715.25
7.0.210.0110.00015.58
7.0.200.0040.00416.07
7.0.190.0030.00615.53
7.0.180.0000.01515.45
7.0.170.0120.00315.54
7.0.160.0110.00615.56
7.0.150.0080.00015.56
7.0.140.0040.04018.78
7.0.130.0030.00915.60
7.0.120.0070.00415.70
7.0.110.0100.00715.60
7.0.100.0000.01515.59
7.0.90.0070.00315.42
7.0.80.0030.00615.31
7.0.70.0070.00715.66
7.0.60.0070.04517.54
7.0.50.0070.03516.62
7.0.40.0070.04216.89
7.0.30.0150.04616.84
7.0.20.0150.03716.85
7.0.10.0160.04016.84
7.0.00.0020.03416.87
5.6.400.0030.01014.47
5.6.390.0030.01014.53
5.6.380.0070.01014.61
5.6.370.0090.00614.42
5.6.360.0120.00314.27
5.6.350.0110.00714.29
5.6.340.0060.00814.05
5.6.330.0040.00714.25
5.6.320.0090.00014.61
5.6.310.0120.00014.61
5.6.300.0000.01214.54
5.6.290.0040.01214.61
5.6.280.0060.03617.86
5.6.270.0070.00714.27
5.6.260.0030.01014.68
5.6.250.0030.01014.32
5.6.240.0000.01314.54
5.6.230.0040.01114.46
5.6.220.0000.01114.43
5.6.210.0020.03017.38
5.6.200.0030.02516.37
5.6.190.0060.03117.44
5.6.180.0250.04017.61
5.6.170.0120.02917.46
5.6.160.0000.02617.41
5.6.150.0070.03116.20
5.6.140.0050.02416.42
5.6.130.0060.02316.29
5.6.120.0090.03917.85
5.6.110.0100.02817.66
5.6.100.0080.04417.64
5.6.90.0090.04217.70
5.6.80.0120.03017.34
5.6.70.0070.00714.39
5.6.60.0120.00414.21
5.6.50.0000.01514.38
5.6.40.0040.01114.26
5.6.30.0000.00814.50
5.6.20.0090.00014.61
5.6.10.0060.00914.46
5.6.00.0030.01414.23
5.5.380.0120.00014.52
5.5.370.0050.00514.40
5.5.360.0000.01114.59
5.5.350.0180.03617.57
5.5.340.0070.04316.22
5.5.330.0110.04217.36
5.5.320.0200.03217.51
5.5.310.0100.03217.44
5.5.300.0060.04316.10
5.5.290.0080.02816.10
5.5.280.0100.04117.62
5.5.270.0100.04217.61
5.5.260.0140.03817.72
5.5.250.0030.03717.41
5.5.240.0100.03917.22
5.5.230.0070.00714.39
5.5.220.0030.00914.26
5.5.210.0030.01414.41
5.5.200.0060.00614.40
5.5.190.0140.00014.50
5.5.180.0060.00613.97
5.5.170.0030.01514.09
5.5.160.0040.01114.14
5.5.150.0090.00314.39
5.5.140.0030.01214.31
5.5.130.0030.01014.14
5.5.120.0140.00013.99
5.5.110.0070.01014.55
5.5.100.0000.00914.53
5.5.90.0080.00314.33
5.5.80.0090.00614.14
5.5.70.0000.01414.41
5.5.60.0060.00614.32
5.5.50.0060.00314.28
5.5.40.0070.00714.45
5.5.30.0000.01414.04
5.5.20.0120.00314.19
5.5.10.0060.00314.06
5.5.00.0090.00314.17
5.4.450.0470.02516.29
5.4.440.0300.02316.16
5.4.430.0380.02016.16
5.4.420.0190.02016.36
5.4.410.0350.02016.24
5.4.400.0580.01716.00
5.4.390.0180.03016.19
5.4.380.0170.02915.94
5.4.370.0190.03015.89
5.4.360.0200.02515.97
5.4.350.0170.03215.87
5.4.340.0210.03115.83
5.4.330.0030.00913.15
5.4.320.0080.02212.84
5.4.310.0090.02712.84
5.4.300.0040.02512.83
5.4.290.0050.02812.83
5.4.280.0040.02312.78
5.4.270.0060.02712.78
5.4.260.0040.02612.78
5.4.250.0070.02112.78
5.4.240.0050.02112.78
5.4.230.0080.01812.78
5.4.220.0080.02212.78
5.4.210.0060.02912.78
5.4.200.0060.02812.78
5.4.190.0030.02412.77
5.4.180.0070.02212.78
5.4.170.0070.02812.78
5.4.160.0040.02212.78
5.4.150.0060.02312.78
5.4.140.0090.01912.62
5.4.130.0080.02312.61
5.4.120.0060.02612.59
5.4.110.0070.02612.59
5.4.100.0080.02712.59
5.4.90.0060.02912.59
5.4.80.0070.02712.59
5.4.70.0060.01912.59
5.4.60.0030.02412.59
5.4.50.0060.02812.59
5.4.40.0070.03412.58
5.4.30.0050.03112.58
5.4.20.0040.03012.58
5.4.10.0070.03012.58
5.4.00.0060.02412.33
5.3.290.0060.02212.98
5.3.280.0050.02812.93
5.3.270.0050.02912.94
5.3.260.0080.03212.94
5.3.250.0050.02612.94
5.3.240.0030.03312.94
5.3.230.0100.02912.94
5.3.220.0070.03412.92
5.3.210.0040.03112.92
5.3.200.0130.03812.92
5.3.190.0050.04712.92
5.3.180.0060.03012.92
5.3.170.0100.02912.92
5.3.160.0100.02312.92
5.3.150.0020.03512.92
5.3.140.0070.02812.91
5.3.130.0040.02712.91
5.3.120.0040.03212.91
5.3.110.0040.02612.91
5.3.100.0040.03212.66
5.3.90.0040.03412.65
5.3.80.0060.02812.64
5.3.70.0070.01812.64
5.3.60.0050.02012.64
5.3.50.0090.02512.61
5.3.40.0060.02912.61
5.3.30.0050.02712.59
5.3.20.0030.02112.48
5.3.10.0020.02712.46
5.3.00.0110.02512.46
5.2.170.0060.0319.19
5.2.160.0060.0429.18
5.2.150.0050.0449.18
5.2.140.0100.0499.18
5.2.130.0060.0419.14
5.2.120.0040.0439.14
5.2.110.0060.0409.15
5.2.100.0040.0449.15
5.2.90.0110.0329.14
5.2.80.0100.0399.14
5.2.70.0080.0429.14
5.2.60.0070.0469.10
5.2.50.0090.0439.06
5.2.40.0100.0399.04
5.2.30.0070.0489.02
5.2.20.0090.0359.01
5.2.10.0050.0398.93
5.2.00.0090.0368.79
5.1.60.0030.0368.07
5.1.50.0090.0268.07
5.1.40.0120.0298.05
5.1.30.0080.0288.39
5.1.20.0100.0328.42
5.1.10.0080.0338.14
5.1.00.0070.0298.14
5.0.50.0040.0206.63
5.0.40.0020.0216.48
5.0.30.0030.0326.30
5.0.20.0010.0226.27
5.0.10.0040.0206.24
5.0.00.0040.0426.24
4.4.90.0050.0204.77
4.4.80.0030.0224.76
4.4.70.0020.0194.75
4.4.60.0040.0204.76
4.4.50.0010.0244.77
4.4.40.0040.0344.71
4.4.30.0050.0184.76
4.4.20.0050.0214.84
4.4.10.0040.0184.85
4.4.00.0030.0334.76
4.3.110.0040.0194.67
4.3.100.0090.0174.66
4.3.90.0030.0224.63
4.3.80.0000.0344.59
4.3.70.0040.0154.63
4.3.60.0050.0194.63
4.3.50.0050.0214.63
4.3.40.0030.0254.53
4.3.30.0020.0183.29
4.3.20.0010.0183.27
4.3.10.0020.0163.22
4.3.00.0070.01316.03

preferences:
46.65 ms | 401 KiB | 5 Q