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 $this->caughtOutput; } 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.0060.01218.28
8.3.50.0050.01222.06
8.3.40.0090.00618.85
8.3.30.0140.00719.04
8.3.20.0000.00720.29
8.3.10.0030.00623.66
8.3.00.0000.00919.38
8.2.180.0150.00416.88
8.2.170.0220.00022.96
8.2.160.0170.00320.39
8.2.150.0060.00324.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0000.00722.07
8.2.110.0000.00922.03
8.2.100.0110.00018.03
8.2.90.0040.00419.35
8.2.80.0000.00917.97
8.2.70.0000.00917.63
8.2.60.0000.00817.93
8.2.50.0030.00618.07
8.2.40.0060.00319.94
8.2.30.0080.00018.07
8.2.20.0000.00817.71
8.2.10.0040.00418.14
8.2.00.0040.00417.81
8.1.280.0090.00625.92
8.1.270.0000.00823.90
8.1.260.0060.00326.35
8.1.250.0000.00728.09
8.1.240.0030.00624.00
8.1.230.0040.00719.11
8.1.220.0040.00417.74
8.1.210.0030.00618.77
8.1.200.0030.00717.48
8.1.190.0000.00817.41
8.1.180.0040.00418.10
8.1.170.0050.00318.41
8.1.160.0040.00422.00
8.1.150.0000.00818.54
8.1.140.0040.00417.48
8.1.130.0070.00017.77
8.1.120.0040.00417.46
8.1.110.0050.00217.35
8.1.100.0050.00217.46
8.1.90.0040.00417.46
8.1.80.0000.00717.41
8.1.70.0000.00717.48
8.1.60.0060.00317.61
8.1.50.0000.00817.51
8.1.40.0000.00717.46
8.1.30.0000.00817.64
8.1.20.0040.00417.63
8.1.10.0060.00317.49
8.1.00.0040.00417.55
8.0.300.0070.00020.61
8.0.290.0000.00717.05
8.0.280.0000.00718.46
8.0.270.0070.00017.17
8.0.260.0060.00017.30
8.0.250.0070.00017.03
8.0.240.0030.00616.94
8.0.230.0050.00217.10
8.0.220.0030.00317.02
8.0.210.0000.00816.95
8.0.200.0030.00317.04
8.0.190.0030.00516.97
8.0.180.0040.00416.98
8.0.170.0080.00016.93
8.0.160.0000.00716.88
8.0.150.0040.00416.90
8.0.140.0070.00016.79
8.0.130.0030.00313.37
8.0.120.0080.00016.84
8.0.110.0000.00716.89
8.0.100.0040.00416.86
8.0.90.0000.00716.87
8.0.80.0050.01016.95
8.0.70.0040.00416.76
8.0.60.0000.00717.10
8.0.50.0000.00716.86
8.0.30.0090.01217.12
8.0.20.0120.00917.40
8.0.10.0080.00017.04
8.0.00.0120.00916.92
7.4.330.0000.00515.09
7.4.320.0030.00316.58
7.4.300.0050.00216.60
7.4.290.0040.00416.54
7.4.280.0050.00216.40
7.4.270.0000.00816.61
7.4.260.0030.00316.52
7.4.250.0050.00216.39
7.4.240.0000.00816.54
7.4.230.0030.00316.55
7.4.220.0070.01016.49
7.4.210.0140.00516.59
7.4.200.0000.00816.32
7.4.190.0030.00316.75
7.4.160.0080.00816.63
7.4.150.0150.00317.40
7.4.140.0050.01317.86
7.4.130.0100.00716.42
7.4.120.0070.01016.64
7.4.110.0100.00716.37
7.4.100.0110.01116.38
7.4.90.0070.01016.46
7.4.80.0060.01619.39
7.4.70.0090.00616.47
7.4.60.0080.01016.52
7.4.50.0040.00416.13
7.4.40.0130.01016.61
7.4.30.0030.01416.59
7.4.00.0080.01014.85
7.3.330.0040.00413.39
7.3.320.0030.00313.20
7.3.310.0040.00416.24
7.3.300.0040.00416.44
7.3.290.0120.00616.35
7.3.280.0030.01416.38
7.3.270.0180.00017.40
7.3.260.0090.00916.66
7.3.250.0110.00716.51
7.3.240.0070.01016.69
7.3.230.0100.00716.60
7.3.210.0070.01116.63
7.3.200.0020.01819.39
7.3.190.0060.01416.45
7.3.180.0060.01016.54
7.3.170.0060.01116.67
7.3.160.0040.01116.39
7.3.120.0050.01014.76
7.3.110.0030.01414.86
7.3.100.0040.01414.90
7.3.90.0030.01014.91
7.3.80.0030.01315.06
7.3.70.0030.00614.64
7.3.60.0080.00814.73
7.3.50.0000.01314.77
7.3.40.0060.00614.65
7.3.30.0070.00714.70
7.3.20.0000.01016.83
7.3.10.0060.00616.48
7.3.00.0090.00616.84
7.2.330.0120.01216.43
7.2.320.0100.00716.79
7.2.310.0030.01416.73
7.2.300.0120.01216.54
7.2.290.0130.00916.91
7.2.250.0110.00415.28
7.2.240.0070.01115.30
7.2.230.0000.01815.13
7.2.220.0070.00314.89
7.2.210.0030.01215.05
7.2.200.0100.00314.95
7.2.190.0030.01315.16
7.2.180.0070.00715.23
7.2.170.0000.01215.16
7.2.60.0060.00916.68
7.2.00.0000.01019.60
7.1.330.0060.00615.63
7.1.320.0000.00916.04
7.1.310.0110.00315.71
7.1.300.0070.00715.70
7.1.290.0100.00715.50
7.1.280.0040.00815.58
7.1.270.0070.01015.87
7.1.260.0120.00315.77
7.1.200.0040.00815.72
7.1.100.0000.01218.13
7.1.70.0070.00017.19
7.1.60.0090.00919.46
7.1.50.0160.01916.71
7.1.00.0100.06722.57
7.0.200.0000.00716.85
7.0.140.0070.07022.09
7.0.100.0070.04720.05
7.0.90.0030.08720.00
7.0.80.0170.07019.93
7.0.70.0370.07320.05
7.0.60.0100.08020.00
7.0.50.0000.04720.45
7.0.40.0130.07720.13
7.0.30.0000.06320.17
7.0.20.0070.08020.05
7.0.10.0200.07720.07
7.0.00.0030.08720.06
5.6.280.0030.07321.13
5.6.250.0030.08020.62
5.6.240.0170.06720.62
5.6.230.0030.08720.68
5.6.220.0030.04320.67
5.6.210.0100.08020.69
5.6.200.0070.05021.09
5.6.190.0030.05321.19
5.6.180.0230.07021.07
5.6.170.0070.09021.04
5.6.160.0030.09020.98
5.6.150.0230.04020.96
5.6.140.0000.04721.13
5.6.130.0070.04021.12
5.6.120.0030.04021.11
5.6.110.0030.04321.04
5.6.100.0030.04720.96
5.6.90.0130.04321.02
5.6.80.0170.03020.40
5.6.70.0070.03020.42
5.6.60.0030.03320.47
5.6.50.0030.03720.43
5.6.40.0030.05720.44
5.6.30.0030.04020.41
5.6.20.0070.04020.48
5.6.10.0030.03320.42
5.6.00.0030.04020.41
5.5.380.0100.08020.41
5.5.370.0200.07020.57
5.5.360.0130.08320.50
5.5.350.0000.05720.36
5.5.340.0070.07720.82
5.5.330.0100.08020.85
5.5.320.0100.07720.75
5.5.310.0030.05020.82
5.5.300.0070.05020.79
5.5.290.0070.04320.66
5.5.280.0070.03720.93
5.5.270.0070.03720.87
5.5.260.0130.03320.89
5.5.250.0070.03720.70
5.5.240.0000.04720.18
5.5.230.0030.04020.26
5.5.220.0070.03020.32
5.5.210.0030.04720.26
5.5.200.0000.03720.11
5.5.190.0000.04320.27
5.5.180.0030.03720.02
5.5.160.0030.03720.21
5.5.150.0070.03320.25
5.5.140.0000.06020.14
5.5.130.0100.03320.01
5.5.120.0030.04020.27
5.5.110.0100.03720.28
5.5.100.0070.03720.04
5.5.90.0030.04020.08
5.5.80.0000.03320.11
5.5.70.0100.03320.11
5.5.60.0070.03720.06
5.5.50.0030.04020.05
5.5.40.0100.05320.09
5.5.30.0000.04020.06
5.5.20.0000.04320.05
5.5.10.0070.03020.14
5.5.00.0030.04019.99
5.4.450.0000.04319.54
5.4.440.0100.04019.53
5.4.430.0000.04319.48
5.4.420.0030.04019.48
5.4.410.0030.04019.04
5.4.400.0100.03319.18
5.4.390.0170.02719.21
5.4.380.0130.06318.95
5.4.370.0130.02319.03
5.4.360.0030.03319.13
5.4.350.0030.04319.00
5.4.340.0030.04019.10
5.4.320.0030.04318.90
5.4.310.0000.05719.13
5.4.300.0030.03719.23
5.4.290.0000.04019.04
5.4.280.0100.03019.14
5.4.270.0000.03719.12
5.4.260.0030.03319.18
5.4.250.0000.04019.08
5.4.240.0130.02019.12
5.4.230.0030.03018.93
5.4.220.0000.04319.04
5.4.210.0030.03719.03
5.4.200.0000.04019.12
5.4.190.0030.04019.13
5.4.180.0000.04018.89
5.4.170.0000.03319.22
5.4.160.0030.03719.10
5.4.150.0070.06719.04
5.4.140.0070.07316.34
5.4.130.0100.06716.36
5.4.120.0000.03716.20
5.4.110.0100.03716.47
5.4.100.0070.06316.34
5.4.90.0030.08016.51
5.4.80.0100.05316.42
5.4.70.0030.07016.41
5.4.60.0070.04316.47
5.4.50.0130.06316.43
5.4.40.0070.05716.36
5.4.30.0130.03716.30
5.4.20.0100.05016.42
5.4.10.0000.05716.36
5.4.00.0070.05715.88
5.3.290.0000.03314.69
5.3.280.0000.04014.57
5.3.270.0030.04014.65
5.3.260.0030.03714.69
5.3.250.0000.03714.64
5.3.240.0070.07014.69
5.3.230.0030.07314.59
5.3.220.0000.04014.66
5.3.210.0130.06714.52
5.3.200.0030.04714.63
5.3.190.0030.04014.73
5.3.180.0070.03714.56
5.3.170.0030.03714.65
5.3.160.0070.04714.73
5.3.150.0030.07014.63
5.3.140.0030.07314.65
5.3.130.0070.08014.61
5.3.120.0100.05014.67
5.3.110.0100.06014.54
5.3.100.0070.07314.21
5.3.90.0100.06314.08
5.3.80.0030.04714.10
5.3.70.0070.04314.16
5.3.60.0030.07714.01
5.3.50.0000.05713.91
5.3.40.0070.08013.86
5.3.30.0200.06314.08
5.3.20.0030.07313.79
5.3.10.0030.06313.61
5.3.00.0100.03713.68
5.2.170.0000.06011.14
5.2.160.0000.04311.11
5.2.150.0030.06311.14
5.2.140.0000.06011.22
5.2.130.0100.05710.89
5.2.120.0000.04711.05
5.2.110.0100.06310.92
5.2.100.0030.06011.09
5.2.90.0030.05311.17
5.2.80.0070.05711.04
5.2.70.0100.05711.09
5.2.60.0070.05311.01
5.2.50.0100.05710.96
5.2.40.0000.04710.85
5.2.30.0070.04710.97
5.2.20.0070.05710.95
5.2.10.0130.04010.88
5.2.00.0100.05010.76
5.1.60.0000.03710.06
5.1.50.0000.0439.98
5.1.40.0030.05710.06
5.1.30.0030.02710.38
5.1.20.0070.05010.39
5.1.10.0030.02310.07
5.1.00.0030.05310.10
5.0.50.0030.0409.54
5.0.40.0030.0239.54
5.0.30.0030.0579.54
5.0.20.0100.0309.54
5.0.10.0030.0409.54
5.0.00.0030.0309.54
4.4.90.0030.0179.54
4.4.80.0000.0309.54
4.4.70.0000.0379.54
4.4.60.0070.0309.54
4.4.50.0030.0379.54
4.4.40.0000.0409.54
4.4.30.0030.0339.54
4.4.20.0000.0379.54
4.4.10.0000.0239.54
4.4.00.0030.0379.54
4.3.110.0000.0309.54
4.3.100.0030.0139.54
4.3.90.0030.0179.54
4.3.80.0000.0279.54
4.3.70.0000.0339.54
4.3.60.0000.0279.54
4.3.50.0000.0179.54
4.3.40.0000.0379.54
4.3.30.0030.0239.54
4.3.20.0000.0239.54
4.3.10.0000.0339.54
4.3.00.0030.0339.54

preferences:
49.67 ms | 401 KiB | 5 Q