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(...$params): Closable { return new self(...$params); } } 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.120.0260.01117.34
8.3.110.0410.00316.42
8.3.100.0240.00816.24
8.3.90.0080.01516.58
8.3.80.0210.01416.46
8.3.70.0380.00716.61
8.3.60.0380.01116.72
8.3.50.0350.00616.57
8.3.40.0130.00517.52
8.3.30.0180.00417.47
8.3.20.0200.01717.34
8.3.10.0240.00317.46
8.3.00.0170.01019.48
8.2.230.0140.00718.27
8.2.220.0230.01616.59
8.2.210.0380.00416.28
8.2.200.0340.01016.71
8.2.190.0210.01716.64
8.2.180.0330.00716.45
8.2.170.0310.00817.81
8.2.160.0320.00317.70
8.2.150.0300.01217.51
8.2.140.0280.01617.48
8.2.130.0360.00717.58
8.2.120.0410.00417.50
8.2.110.0290.01417.43
8.2.100.0350.00717.63
8.2.90.0450.00717.55
8.2.80.0560.00317.34
8.2.70.0290.01317.51
8.2.60.0370.00717.40
8.2.50.0310.01017.35
8.2.40.0290.00617.38
8.2.30.0360.00317.58
8.2.20.0300.01017.57
8.2.10.0270.01217.52
8.2.00.0320.00417.57
8.1.290.0250.01416.14
8.1.280.0270.01416.17
8.1.270.0340.00616.98
8.1.260.0350.00917.19
8.1.250.0210.00317.29
8.1.240.0230.00317.09
8.1.230.0150.01517.39
8.1.220.0190.01617.23
8.1.210.0230.01917.32
8.1.200.0310.00017.17
8.1.190.0240.00716.90
8.1.180.0320.00616.98
8.1.170.0250.01117.04
8.1.160.0360.00416.96
8.1.150.0230.01616.96
8.1.140.0390.00016.92
8.1.130.0300.00917.00
8.1.120.0290.01117.06
8.1.110.0280.01017.05
8.1.100.0360.01617.26
8.1.90.0320.00717.04
8.1.80.0310.00816.96
8.1.70.0300.00017.18
8.1.60.0130.00717.14
8.1.50.0380.00417.32
8.1.40.0360.00617.30
8.1.30.0340.01117.21
8.1.20.0370.00417.11
8.1.10.0220.01316.89
8.1.00.0330.00617.34

preferences:
19.3 ms | 403 KiB | 5 Q