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 456; echo strlen($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.0140.00316.63
8.3.50.0120.00522.11
8.3.40.0110.00319.04
8.3.30.0110.00719.21
8.3.20.0040.00420.35
8.3.10.0060.00323.48
8.3.00.0080.00019.13
8.2.180.0060.01016.75
8.2.170.0110.01122.96
8.2.160.0070.01320.43
8.2.150.0080.00024.18
8.2.140.0040.00424.66
8.2.130.0080.00026.16
8.2.120.0040.00422.09
8.2.110.0100.00020.31
8.2.100.0110.00017.84
8.2.90.0040.00419.17
8.2.80.0000.00818.03
8.2.70.0040.00417.75
8.2.60.0040.00417.93
8.2.50.0000.00818.07
8.2.40.0060.00319.82
8.2.30.0000.00719.98
8.2.20.0080.00017.91
8.2.10.0030.00618.16
8.2.00.0070.00317.84
8.1.280.0070.00725.92
8.1.270.0080.00024.01
8.1.260.0000.00826.35
8.1.250.0040.00428.09
8.1.240.0060.00322.63
8.1.230.0040.00720.89
8.1.220.0000.00817.74
8.1.210.0070.00718.77
8.1.200.0000.00917.13
8.1.190.0050.00317.22
8.1.180.0050.00518.10
8.1.170.0040.00418.67
8.1.160.0020.00522.00
8.1.150.0030.00618.59
8.1.140.0040.00417.48
8.1.130.0000.00717.89
8.1.120.0070.00017.39
8.1.110.0030.00517.54
8.1.100.0040.00417.55
8.1.90.0000.00717.40
8.1.80.0000.00817.45
8.1.70.0030.00617.46
8.1.60.0050.00517.53
8.1.50.0050.00317.57
8.1.40.0030.00517.44
8.1.30.0030.00517.57
8.1.20.0060.00317.69
8.1.10.0040.00417.61
8.1.00.0000.00817.54
8.0.300.0000.00820.61
8.0.290.0060.00317.16
8.0.280.0040.00418.53
8.0.270.0050.00216.82
8.0.260.0000.00717.30
8.0.250.0070.00017.05
8.0.240.0040.00417.06
8.0.230.0040.00417.07
8.0.220.0070.00017.00
8.0.210.0050.00217.00
8.0.200.0030.00316.91
8.0.190.0050.00217.02
8.0.180.0070.00016.90
8.0.170.0030.00617.06
8.0.160.0000.00716.87
8.0.150.0050.00316.93
8.0.140.0000.00917.01
8.0.130.0060.00013.46
8.0.120.0080.00016.92
8.0.110.0030.00516.99
8.0.100.0040.00416.92
8.0.90.0040.00416.93
8.0.80.0070.01016.94
8.0.70.0030.00616.94
8.0.60.0040.00416.98
8.0.50.0040.00416.88
8.0.30.0090.01017.23
8.0.20.0100.01017.40
8.0.10.0040.00416.97
8.0.00.0090.00916.60
7.4.330.0060.00015.14
7.4.320.0070.00016.63
7.4.300.0060.00016.61
7.4.290.0030.00316.47
7.4.280.0080.00016.67
7.4.270.0030.00516.61
7.4.260.0000.00716.63
7.4.250.0040.00416.51
7.4.240.0030.00316.59
7.4.230.0040.00416.61
7.4.220.0160.00316.66
7.4.210.0100.00616.59
7.4.200.0030.00616.67
7.4.190.0000.00716.70
7.4.160.0090.00916.48
7.4.150.0060.01217.40
7.4.140.0130.00817.86
7.4.130.0100.01216.54
7.4.120.0060.01216.56
7.4.110.0170.00816.43
7.4.100.0110.00716.70
7.4.90.0090.00916.45
7.4.80.0170.00619.39
7.4.70.0100.00716.47
7.4.60.0060.00916.52
7.4.50.0030.00616.61
7.4.40.0090.00916.55
7.4.30.0130.00316.38
7.4.00.0100.00714.96
7.3.330.0030.00313.36
7.3.320.0030.00313.42
7.3.310.0040.00416.22
7.3.300.0000.00716.42
7.3.290.0100.00416.40
7.3.280.0070.00916.37
7.3.270.0130.00617.40
7.3.260.0060.01216.42
7.3.250.0080.01516.42
7.3.240.0060.01016.57
7.3.230.0000.01516.39
7.3.210.0150.00416.43
7.3.200.0080.01119.39
7.3.190.0110.00816.40
7.3.180.0130.00316.45
7.3.170.0000.01716.54
7.3.160.0080.00816.55
7.3.120.0130.00715.09
7.3.110.0000.01515.03
7.3.100.0040.00814.81
7.3.90.0130.00314.96
7.3.80.0070.00715.06
7.3.70.0000.01414.91
7.3.60.0070.01014.80
7.3.50.0110.00414.64
7.3.40.0030.01014.66
7.3.30.0070.00714.56
7.3.20.0030.01416.82
7.3.10.0060.00316.46
7.3.00.0030.01016.74
7.2.330.0130.00616.78
7.2.320.0160.00016.82
7.2.310.0100.01016.61
7.2.300.0060.01016.48
7.2.290.0110.00616.89
7.2.250.0130.00715.31
7.2.240.0030.01715.05
7.2.230.0040.01415.26
7.2.220.0000.01415.29
7.2.210.0070.00715.16
7.2.200.0070.00315.17
7.2.190.0030.00615.09
7.2.180.0070.01014.98
7.2.170.0090.00615.14
7.2.160.0070.00315.27
7.2.150.0060.00917.06
7.2.140.0090.00316.91
7.2.130.0060.00916.70
7.2.120.0150.00417.09
7.2.110.0000.01617.14
7.2.100.0080.00417.10
7.2.90.0100.00316.89
7.2.80.0120.00316.91
7.2.70.0030.01216.90
7.2.60.0080.00816.80
7.2.50.0070.00716.78
7.2.40.0000.01017.03
7.2.30.0070.00717.13
7.2.20.0070.00316.80
7.2.10.0030.00916.98
7.2.00.0020.01018.31
7.1.330.0060.01015.53
7.1.320.0030.00915.88
7.1.310.0030.00715.80
7.1.300.0070.00715.82
7.1.290.0060.00615.77
7.1.280.0040.01115.65
7.1.270.0040.01115.79
7.1.260.0030.01015.70
7.1.250.0040.01115.75
7.1.200.0310.00015.35
7.1.100.0060.00918.19
7.1.70.0040.01216.86
7.1.60.0150.00319.46
7.1.50.0030.02016.57
7.1.00.0000.08022.45
7.0.200.0030.00316.88
7.0.140.0030.07322.21
7.0.60.0000.04320.00
7.0.50.0030.06017.89
7.0.40.0070.08720.11
7.0.30.0200.04320.26
7.0.20.0200.05720.02
7.0.10.0030.04320.21
7.0.00.0070.05720.32
5.6.280.0070.07020.95
5.6.210.0130.07320.51
5.6.200.0100.04718.16
5.6.190.0230.08020.45
5.6.180.0000.09020.48
5.6.170.0100.04720.50
5.6.160.0100.05020.44
5.6.150.0100.03718.14
5.6.140.0030.08718.18
5.6.130.0030.08318.15
5.6.120.0170.07721.04
5.6.110.0130.07720.98
5.6.100.0030.08720.99
5.6.90.0070.07020.99
5.6.80.0100.03320.39
5.5.350.0100.04720.41
5.5.340.0030.07018.09
5.5.330.0030.07320.41
5.5.320.0100.04320.27
5.5.310.0200.04020.35
5.5.300.0130.06717.98
5.5.290.0130.06317.99
5.5.280.0100.06720.79
5.5.270.0070.05320.81
5.5.260.0100.04720.96
5.5.250.0000.06720.73
5.5.240.0100.04320.18
5.4.450.0230.05719.48
5.4.440.0100.06319.20
5.4.430.0270.04719.54
5.4.420.0070.06719.63
5.4.410.0170.05319.07
5.4.400.0130.06719.38
5.4.390.0130.06019.14
5.4.380.0100.05718.75
5.4.370.0170.05318.84
5.4.360.0170.04718.58
5.4.350.0070.06018.61
5.4.340.0230.04718.78
5.4.320.0050.03912.52
5.4.310.0040.04012.52
5.4.300.0060.04012.52
5.4.290.0110.03712.51
5.4.280.0080.04712.41
5.4.270.0130.05912.41
5.4.260.0150.05712.41
5.4.250.0040.04012.41
5.4.240.0120.03112.41
5.4.230.0040.04312.40
5.4.220.0060.04012.40
5.4.210.0110.04112.40
5.4.200.0070.05812.40
5.4.190.0090.05312.40
5.4.180.0070.05412.40
5.4.170.0080.05612.41
5.4.160.0100.04412.41
5.4.150.0130.10512.40
5.4.140.0110.05212.09
5.4.130.0150.07712.07
5.4.120.0110.06812.03
5.4.110.0110.06212.02
5.4.100.0140.07012.03
5.4.90.0080.06312.03
5.4.80.0130.05612.03
5.4.70.0100.04112.02
5.4.60.0070.03812.03
5.4.50.0060.05312.02
5.4.40.0100.04012.02
5.4.30.0110.05812.01
5.4.20.0070.05312.00
5.4.10.0120.05412.01
5.4.00.0090.04811.50
5.3.290.0100.05312.80
5.3.280.0120.04212.71
5.3.270.0100.05612.73
5.3.260.0100.07612.73
5.3.250.0090.05212.73
5.3.240.0100.06112.73
5.3.230.0130.07912.72
5.3.220.0090.05712.70
5.3.210.0160.06312.69
5.3.200.0120.05412.69
5.3.190.0150.10612.69
5.3.180.0190.07112.69
5.3.170.0110.07812.69
5.3.160.0100.07012.69
5.3.150.0160.08512.69
5.3.140.0250.14712.68
5.3.130.0110.04412.68
5.3.120.0090.05112.68
5.3.110.0070.06012.68
5.3.100.0050.04112.16
5.3.90.0120.05212.14
5.3.80.0070.05612.13
5.3.70.0090.05512.13
5.3.60.0150.15712.12
5.3.50.0150.07912.07
5.3.40.0170.06812.07
5.3.30.0250.09912.03
5.3.20.0080.03511.80
5.3.10.0080.04311.77
5.3.00.0050.06111.76
5.2.170.0050.0369.18
5.2.160.0040.0319.19
5.2.150.0050.0339.19
5.2.140.0040.0369.18
5.2.130.0080.0339.14
5.2.120.0050.0329.14
5.2.110.0060.0329.15
5.2.100.0080.0439.15
5.2.90.0040.0449.15
5.2.80.0090.0389.14
5.2.70.0050.0519.14
5.2.60.0110.0379.10
5.2.50.0100.0589.07
5.2.40.0090.0739.04
5.2.30.0060.0429.02
5.2.20.0070.0739.01
5.2.10.0070.0388.93
5.2.00.0110.0288.78
5.1.60.0060.0288.07
5.1.50.0050.0288.07
5.1.40.0060.0258.05
5.1.30.0020.0308.40
5.1.20.0060.0328.42
5.1.10.0060.0348.14
5.1.00.0050.0318.14
5.0.50.0040.0226.63
5.0.40.0020.0226.48
5.0.30.0040.0416.29
5.0.20.0070.0206.27
5.0.10.0150.0766.25
5.0.00.0080.0386.24
4.4.90.0040.0244.78
4.4.80.0040.0244.75
4.4.70.0070.0404.76
4.4.60.0060.0354.76
4.4.50.0110.0314.77
4.4.40.0070.0244.71
4.4.30.0040.0144.76
4.4.20.0010.0234.84
4.4.10.0030.0164.85
4.4.00.0080.0444.76
4.3.110.0070.0334.67
4.3.100.0100.0344.66
4.3.90.0060.0224.63
4.3.80.0050.0424.58
4.3.70.0070.0464.63
4.3.60.0040.0194.63
4.3.50.0010.0184.63
4.3.40.0070.0214.53
4.3.30.0040.0153.29
4.3.20.0020.0173.26
4.3.10.0020.0163.22
4.3.00.0070.0177.53

preferences:
44.47 ms | 401 KiB | 5 Q