3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Closable { public readonly string $key; private bool $closed = false; public function __construct( ?string $key = null, ) { $this->key = uniqid($key ?: 'closable_'); $this->e('__construct'); } private function e(string $out): void { echo $this->key, ': ', $out, "\n"; } public function close(): void { $this->e('close'); $this->e($this->closed ? 'already closed' : 'closing'); $this->closed = true; } public function __destruct() { $this->e('__destruct'); $this->close(); } public static function make(): Closable { return new self(); } } function a(): void { echo "a() start\n"; $a = Closable::make('$a'); echo "a() end\n"; } function b(): void { echo "b() start\n"; $b = Closable::make('$b'); try { if (rand(0,1)) { throw new Exception('b()'); } echo "b() return\n"; unset($b); return; } catch (Exception) { echo "b() catch\n"; } finally { echo "b() finally\n"; isset($b) ? $b->close() : null; } } Closable::make('first'); $foo = Closable::make('$foo'); Closable::make('third'); for ($i = 0; $i <= 10; $i++) { a(); b(); }

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.110.0370.00716.69
8.3.100.0420.00716.57
8.3.90.0310.01016.41
8.3.80.0410.00316.66
8.3.70.0430.00716.59
8.3.60.0310.01416.18
8.3.50.0360.01416.27
8.3.40.0460.00317.48
8.3.30.0340.00817.56
8.3.20.0310.01217.59
8.3.10.0320.01217.44
8.3.00.0170.01319.27
8.2.230.0260.01416.40
8.2.220.0260.01116.40
8.2.210.0300.00016.46
8.2.200.0220.00316.46
8.2.190.0240.00016.73
8.2.180.0230.00416.72
8.2.170.0300.00417.93
8.2.160.0110.01117.40
8.2.150.0210.00017.49
8.2.140.0320.00317.64
8.2.130.0190.00617.35
8.2.120.0210.00017.63
8.2.110.0350.00717.74
8.2.100.0240.00517.35
8.2.90.0210.00017.48
8.2.80.0190.00017.63
8.2.70.0220.00317.46
8.2.60.0060.00619.40
8.2.50.0160.00417.38
8.2.40.0120.00717.53
8.2.30.0170.00317.36
8.2.20.0250.00017.40
8.2.10.0180.00417.36
8.2.00.0120.00817.63
8.1.290.0050.01515.93
8.1.280.0140.00616.04
8.1.270.0170.00317.12
8.1.260.0200.00017.14
8.1.250.0180.00317.35
8.1.240.0110.00817.25
8.1.230.0180.00017.07
8.1.220.0090.00917.10
8.1.210.0190.00817.12
8.1.200.0160.00217.15
8.1.190.0280.00416.91
8.1.180.0280.00417.10
8.1.170.0250.01417.19
8.1.160.0360.00717.01
8.1.150.0340.00317.31
8.1.140.0240.01416.84
8.1.130.0270.00816.89
8.1.120.0170.01717.15
8.1.110.0240.01017.13
8.1.100.0230.00916.98
8.1.90.0240.00917.04
8.1.80.0190.01617.08
8.1.70.0260.01217.16
8.1.60.0270.01217.39
8.1.50.0150.00617.20
8.1.40.0080.01217.30
8.1.30.0200.00017.32
8.1.20.0150.00417.29
8.1.10.0200.00017.36
8.1.00.0170.00317.25

preferences:
27.4 ms | 403 KiB | 5 Q