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(); ob_end_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.0100.00718.43
8.3.50.0070.00921.93
8.3.40.0090.00918.94
8.3.30.0080.00819.26
8.3.20.0070.00020.07
8.3.10.0080.00023.48
8.3.00.0050.00319.38
8.2.180.0150.00018.29
8.2.170.0000.01522.96
8.2.160.0030.01020.47
8.2.150.0060.00324.18
8.2.140.0080.00024.66
8.2.130.0100.00726.16
8.2.120.0080.00022.13
8.2.110.0140.00722.16
8.2.100.0060.00617.97
8.2.90.0030.00619.30
8.2.80.0040.00417.97
8.2.70.0000.00917.75
8.2.60.0030.00518.16
8.2.50.0040.00418.07
8.2.40.0000.00919.82
8.2.30.0050.00218.15
8.2.20.0000.00917.89
8.2.10.0040.00418.21
8.2.00.0050.00517.71
8.1.280.0090.00625.92
8.1.270.0000.00823.97
8.1.260.0040.00426.35
8.1.250.0000.00828.09
8.1.240.0030.00623.71
8.1.230.0040.00719.00
8.1.220.0050.00317.74
8.1.210.0030.00518.77
8.1.200.0030.00617.47
8.1.190.0040.00417.55
8.1.180.0060.00318.10
8.1.170.0000.00818.57
8.1.160.0000.00822.02
8.1.150.0070.00318.61
8.1.140.0040.00417.48
8.1.130.0030.00317.73
8.1.120.0040.00417.54
8.1.110.0000.00817.56
8.1.100.0040.00417.49
8.1.90.0040.00417.40
8.1.80.0040.00417.46
8.1.70.0040.00417.45
8.1.60.0040.00417.55
8.1.50.0000.00717.44
8.1.40.0050.00317.41
8.1.30.0080.00017.51
8.1.20.0040.00417.60
8.1.10.0050.00317.50
8.1.00.0070.00017.52
8.0.300.0030.00518.77
8.0.290.0040.00417.18
8.0.280.0030.00518.35
8.0.270.0050.00317.13
8.0.260.0050.00317.30
8.0.250.0070.00016.91
8.0.240.0060.00017.01
8.0.230.0030.00316.88
8.0.220.0070.00016.89
8.0.210.0040.00416.91
8.0.200.0030.00317.05
8.0.190.0000.00816.93
8.0.180.0000.00716.91
8.0.170.0040.00417.03
8.0.160.0030.00317.01
8.0.150.0040.00417.02
8.0.140.0000.00716.91
8.0.130.0030.00313.36
8.0.120.0000.00816.98
8.0.110.0050.00216.97
8.0.100.0070.00017.04
8.0.90.0000.00717.01
8.0.80.0060.00916.91
8.0.70.0080.00016.82
8.0.60.0080.00017.01
8.0.50.0000.00716.93
8.0.30.0100.01017.28
8.0.20.0060.01617.40
8.0.10.0050.00217.13
8.0.00.0090.01117.02
7.4.330.0020.00315.02
7.4.320.0000.00816.61
7.4.300.0040.00416.50
7.4.290.0000.00716.58
7.4.280.0030.00616.64
7.4.270.0000.00716.56
7.4.260.0050.00316.46
7.4.250.0040.00416.58
7.4.240.0040.00316.53
7.4.230.0070.00016.53
7.4.220.0110.01416.63
7.4.210.0100.00616.56
7.4.200.0060.00316.66
7.4.190.0030.00316.59
7.4.160.0100.00616.64
7.4.150.0140.00317.40
7.4.140.0130.01117.86
7.4.130.0100.00716.60
7.4.120.0160.00316.67
7.4.110.0060.01216.53
7.4.100.0120.00816.57
7.4.90.0100.00716.52
7.4.80.0060.01519.39
7.4.70.0110.00716.52
7.4.60.0160.00016.49
7.4.50.0000.00916.59
7.4.40.0070.01816.51
7.4.30.0090.00916.47
7.4.10.0060.01314.91
7.4.00.0060.01015.13
7.3.330.0060.00013.39
7.3.320.0000.00513.21
7.3.310.0020.00516.45
7.3.300.0040.00416.41
7.3.290.0060.00916.37
7.3.280.0090.00916.36
7.3.270.0030.01617.40
7.3.260.0090.01516.61
7.3.250.0130.00516.39
7.3.240.0060.01416.47
7.3.230.0130.00616.47
7.3.210.0080.01516.58
7.3.200.0060.01619.39
7.3.190.0060.01216.50
7.3.180.0080.00716.62
7.3.170.0040.01216.42
7.3.160.0130.00316.46
7.3.130.0090.01014.97
7.3.120.0040.01114.88
7.3.110.0070.01114.93
7.3.100.0060.01014.83
7.3.90.0060.00914.73
7.3.80.0050.00914.78
7.3.70.0040.00914.80
7.3.60.0050.01014.68
7.3.50.0050.00514.71
7.3.40.0070.00614.76
7.3.30.0070.00814.75
7.3.20.0050.00716.50
7.3.10.0050.00916.63
7.3.00.0020.00916.52
7.2.330.0130.01016.53
7.2.320.0100.00616.54
7.2.310.0120.00616.82
7.2.300.0060.01016.56
7.2.290.0160.00016.84
7.2.260.0030.01515.04
7.2.250.0080.00915.25
7.2.240.0050.00914.94
7.2.230.0080.00815.17
7.2.220.0040.01015.18
7.2.210.0070.00715.21
7.2.200.0040.00814.97
7.2.190.0010.01115.15
7.2.180.0030.00815.01
7.2.170.0090.00815.06
7.2.160.0070.00315.09
7.2.150.0050.01116.82
7.2.140.0090.00516.61
7.2.130.0030.00816.95
7.2.120.0050.01116.87
7.2.110.0050.00816.81
7.2.100.0050.00816.77
7.2.90.0020.01116.79
7.2.80.0030.01016.90
7.2.70.0080.00816.78
7.2.60.0080.00716.91
7.2.50.0020.00716.97
7.2.40.0080.00516.94
7.2.30.0060.00916.88
7.2.20.0070.00716.82
7.2.10.0050.00916.65
7.2.00.0100.00817.02
7.1.330.0040.01115.79
7.1.320.0050.00815.81
7.1.310.0080.00515.77
7.1.300.0080.00715.58
7.1.290.0070.00615.68
7.1.280.0040.00915.91
7.1.270.0050.00715.65
7.1.260.0040.01015.58
7.1.250.0090.00315.68
7.1.240.0100.00315.45
7.1.230.0030.01115.59
7.1.220.0020.01015.70
7.1.210.0100.00315.66
7.1.200.0070.00615.61
7.1.190.0060.00515.65
7.1.180.0020.01115.48
7.1.170.0080.00515.75
7.1.160.0030.00815.83
7.1.150.0070.01015.40
7.1.140.0030.01115.56
7.1.130.0030.00815.65
7.1.120.0080.01015.66
7.1.110.0090.00315.78
7.1.100.0040.00615.72
7.1.90.0090.00315.43
7.1.80.0030.01215.81
7.1.70.0040.00616.33
7.1.60.0060.01017.02
7.1.50.0080.01116.02
7.1.40.0080.00615.68
7.1.30.0020.01315.71
7.1.20.0120.00315.64
7.1.10.0050.00915.49
7.1.00.0030.03117.92
7.0.330.0100.00315.35
7.0.320.0050.00815.29
7.0.310.0040.00615.36
7.0.300.0070.00715.36
7.0.290.0050.00815.08
7.0.280.0070.00715.32
7.0.270.0030.00915.38
7.0.260.0050.01115.39
7.0.250.0070.00715.36
7.0.240.0020.00915.52
7.0.230.0100.00515.28
7.0.220.0060.00415.35
7.0.210.0090.00415.45
7.0.200.0050.00915.88
7.0.190.0060.00415.46
7.0.180.0030.00915.46
7.0.170.0090.00415.17
7.0.160.0050.00815.26
7.0.150.0060.00915.17
7.0.140.0010.03317.57
7.0.130.0030.01315.21
7.0.120.0050.01015.31
7.0.110.0030.01015.35
7.0.100.0030.00815.24
7.0.90.0030.00815.46
7.0.80.0060.00515.26
7.0.70.0040.00915.27
7.0.60.0080.03116.77
7.0.50.0060.01816.22
7.0.40.0040.02415.62
7.0.30.0150.02115.61
7.0.20.0100.03515.55
7.0.10.0110.01815.51
7.0.00.0030.02015.73
5.6.400.0000.01214.60
5.6.390.0100.00514.38
5.6.380.0070.00714.31
5.6.370.0060.00514.42
5.6.360.0000.00914.21
5.6.350.0080.01014.53
5.6.340.0020.01214.41
5.6.330.0110.00414.50
5.6.320.0040.00914.52
5.6.310.0040.01114.26
5.6.300.0080.00314.27
5.6.290.0070.00714.47
5.6.280.0070.02816.62
5.6.270.0020.01114.25
5.6.260.0070.00314.14
5.6.250.0060.00914.15
5.6.240.0050.00914.37
5.6.230.0080.00314.53
5.6.220.0030.01014.46
5.6.210.0080.03016.50
5.6.200.0020.02215.60
5.6.190.0080.03016.50
5.6.180.0040.02016.31
5.6.170.0070.02216.47
5.6.160.0060.03416.37
5.6.150.0030.02115.59
5.6.140.0080.03015.62
5.6.130.0040.03215.61
5.6.120.0050.02016.56
5.6.110.0050.03416.51
5.6.100.0060.03216.51
5.6.90.0050.03416.60
5.6.80.0070.03416.38
5.6.70.0080.00614.29
5.6.60.0050.00814.17
5.6.50.0070.00814.27
5.6.40.0010.00914.32
5.6.30.0050.00814.07
5.6.20.0020.01214.34
5.6.10.0040.00814.37
5.6.00.0010.01014.24
5.5.380.0070.00714.18
5.5.370.0070.00514.37
5.5.360.0030.01014.06
5.5.350.0160.02516.44
5.5.340.0030.02115.31
5.5.330.0040.01716.28
5.5.320.0080.02216.34
5.5.310.0140.01616.30
5.5.300.0030.01915.53
5.5.290.0070.03015.42
5.5.280.0070.03216.36
5.5.270.0100.02916.62
5.5.260.0090.03416.37
5.5.250.0100.02916.18
5.5.240.0050.03016.35
5.5.230.0060.00914.23
5.5.220.0050.01114.30
5.5.210.0050.00814.11
5.5.200.0060.00814.01
5.5.190.0060.00614.46
5.5.180.0070.00814.17
5.5.170.0040.01013.96
5.5.160.0030.00914.06
5.5.150.0060.00714.35
5.5.140.0020.01214.07
5.5.130.0080.00914.41
5.5.120.0060.00914.09
5.5.110.0060.00714.07
5.5.100.0020.01214.08
5.5.90.0080.00514.11
5.5.80.0060.00813.81
5.5.70.0050.01013.91
5.5.60.0090.00514.15
5.5.50.0030.00814.22
5.5.40.0050.00814.03
5.5.30.0020.01214.04
5.5.20.0080.00714.23
5.5.10.0070.00714.04
5.5.00.0030.01014.03
5.4.450.0100.02713.78
5.4.440.0130.02713.88
5.4.430.0110.02313.89
5.4.420.0110.01613.74
5.4.410.0110.02113.81
5.4.400.0140.01713.69
5.4.390.0130.01913.49
5.4.380.0090.01913.71
5.4.370.0080.02013.66
5.4.360.0060.02113.64
5.4.350.0100.02113.44
5.4.340.0060.02013.45
5.4.330.0020.00710.94
5.4.320.0030.01611.48
5.4.310.0060.01711.52
5.4.300.0050.02111.56
5.4.290.0110.01811.61
5.4.280.0070.02411.55
5.4.270.0060.02411.53
5.4.260.0090.03111.62
5.4.250.0120.03111.50
5.4.240.0140.02411.40
5.4.230.0060.02811.33
5.4.220.0080.03511.33
5.4.210.0060.02411.57
5.4.200.0080.02711.43
5.4.190.0090.02711.49
5.4.180.0220.06211.36
5.4.170.0060.02011.31
5.4.160.0060.02811.40
5.4.150.0090.03611.36
5.4.140.0060.02511.20
5.4.130.0060.02411.29
5.4.120.0080.03311.33
5.4.110.0080.02911.40
5.4.100.0070.01511.31
5.4.90.0050.01711.46
5.4.80.0050.01811.31
5.4.70.0050.02111.39
5.4.60.0060.01911.39
5.4.50.0080.03411.22
5.4.40.0100.02011.42
5.4.30.0100.03811.42
5.4.20.0070.03711.26
5.4.10.0070.02211.36
5.4.00.0040.02711.08
5.3.290.0060.01511.36
5.3.280.0050.03411.36
5.3.270.0120.03411.39
5.3.260.0070.03511.44
5.3.250.0050.02311.35
5.3.240.0050.02511.22
5.3.230.0190.04511.24
5.3.220.0090.04411.27
5.3.210.0080.03911.28
5.3.200.0060.02711.20
5.3.190.0090.02711.23
5.3.180.0060.02911.30
5.3.170.0070.03111.35
5.3.160.0040.02411.30
5.3.150.0090.03411.31
5.3.140.0130.03511.33
5.3.130.0070.03711.28
5.3.120.0060.03211.40
5.3.110.0050.02211.23
5.3.100.0110.03511.08
5.3.90.0100.02211.21
5.3.80.0060.02610.97
5.3.70.0100.02811.05
5.3.60.0080.03211.10
5.3.50.0120.02510.98
5.3.40.0040.03011.06
5.3.30.0080.02611.14
5.3.20.0060.02010.95
5.3.10.0060.02010.89
5.3.00.0070.02010.77
5.2.170.0060.0469.18
5.2.160.0040.0609.18
5.2.150.0100.0429.18
5.2.140.0120.0529.18
5.2.130.0140.0619.14
5.2.120.0160.0439.14
5.2.110.0130.0489.15
5.2.100.0030.0579.14
5.2.90.0060.0479.14
5.2.80.0110.0619.14
5.2.70.0060.0469.14
5.2.60.0050.0459.09
5.2.50.0270.0959.07
5.2.40.0100.0369.04
5.2.30.0250.0989.02
5.2.20.0170.0739.01
5.2.10.0060.0588.93
5.2.00.0180.0908.79
5.1.60.0160.0548.07
5.1.50.0210.0638.07
5.1.40.0050.0668.05
5.1.30.0120.0498.40
5.1.20.0130.0538.42
5.1.10.0040.0328.15
5.1.00.0060.0248.14
5.0.50.0050.0196.62
5.0.40.0050.0176.48
5.0.30.0060.0456.30
5.0.20.0060.0316.27
5.0.10.0080.0326.24
5.0.00.0040.0386.24
4.4.90.0060.0304.78
4.4.80.0100.0334.76
4.4.70.0040.0244.75
4.4.60.0030.0234.75
4.4.50.0030.0284.77
4.4.40.0060.0694.71
4.4.30.0060.0394.76
4.4.20.0140.0374.84
4.4.10.0040.0394.85
4.4.00.0070.0344.76
4.3.110.0030.0364.67
4.3.100.0030.0234.66
4.3.90.0030.0344.63
4.3.80.0100.0724.58
4.3.70.0000.0194.63
4.3.60.0000.0204.63
4.3.50.0060.0414.63
4.3.40.0010.0274.54
4.3.30.0030.0213.29
4.3.20.0030.0153.26
4.3.10.0030.0153.22
4.3.00.0000.0277.54

preferences:
61.73 ms | 400 KiB | 5 Q