3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Closable { public readonly string $key; private bool $closed = false; public function __construct() { $this->key = uniqid('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 ? 'closed' : 'open'); $this->closed = true; } public function __destroy(): void { $this->e('__destroy'); $this->close(); } public static function make(): Closable { return new self(); } } function a(): void { echo "a() start\n"; $a = Closable::make(); echo "a() end\n"; } function b(): void { echo "b() start\n"; $b = Closable::make(); 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"; $b?->close(); } } Closable::make(); $foo = Closable::make(); Closable::make(); for ($i = 0; $i <= 10; $i++) { a(); b(); }
Output for git.master_jit
closable_66e93e8505bf3: __construct closable_66e93e8505c0e: __construct closable_66e93e8505c13: __construct a() start closable_66e93e8505c17: __construct a() end b() start closable_66e93e8505c1c: __construct b() catch b() finally closable_66e93e8505c1c: close closable_66e93e8505c1c: open a() start closable_66e93e8505c48: __construct a() end b() start closable_66e93e8505c4e: __construct b() catch b() finally closable_66e93e8505c4e: close closable_66e93e8505c4e: open a() start closable_66e93e8505c5b: __construct a() end b() start closable_66e93e8505c60: __construct b() catch b() finally closable_66e93e8505c60: close closable_66e93e8505c60: open a() start closable_66e93e8505c6c: __construct a() end b() start closable_66e93e8505c71: __construct b() catch b() finally closable_66e93e8505c71: close closable_66e93e8505c71: open a() start closable_66e93e8505c7e: __construct a() end b() start closable_66e93e8505c84: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8505c95: __construct a() end b() start closable_66e93e8505c9a: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8505ca2: __construct a() end b() start closable_66e93e8505ca7: __construct b() catch b() finally closable_66e93e8505ca7: close closable_66e93e8505ca7: open a() start closable_66e93e8505cb5: __construct a() end b() start closable_66e93e8505cba: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8505cc1: __construct a() end b() start closable_66e93e8505cc6: __construct b() catch b() finally closable_66e93e8505cc6: close closable_66e93e8505cc6: open a() start closable_66e93e8505cd3: __construct a() end b() start closable_66e93e8505cd7: __construct b() catch b() finally closable_66e93e8505cd7: close closable_66e93e8505cd7: open a() start closable_66e93e8505ce4: __construct a() end b() start closable_66e93e8505ce8: __construct b() catch b() finally closable_66e93e8505ce8: close closable_66e93e8505ce8: open
Output for git.master
closable_66e93e85018c6: __construct closable_66e93e85018e8: __construct closable_66e93e85018ee: __construct a() start closable_66e93e85018f4: __construct a() end b() start closable_66e93e85018fc: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e850191c: __construct a() end b() start closable_66e93e8501921: __construct b() catch b() finally closable_66e93e8501921: close closable_66e93e8501921: open a() start closable_66e93e850193b: __construct a() end b() start closable_66e93e8501940: __construct b() catch b() finally closable_66e93e8501940: close closable_66e93e8501940: open a() start closable_66e93e8501950: __construct a() end b() start closable_66e93e8501957: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8501961: __construct a() end b() start closable_66e93e8501967: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8501970: __construct a() end b() start closable_66e93e8501975: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e850197e: __construct a() end b() start closable_66e93e8501984: __construct b() catch b() finally closable_66e93e8501984: close closable_66e93e8501984: open a() start closable_66e93e85019a0: __construct a() end b() start closable_66e93e85019a6: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e85019b0: __construct a() end b() start closable_66e93e85019b6: __construct b() catch b() finally closable_66e93e85019b6: close closable_66e93e85019b6: open a() start closable_66e93e85019c5: __construct a() end b() start closable_66e93e85019cb: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e85019d4: __construct a() end b() start closable_66e93e85019da: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59
Output for rfc.property-hooks
closable_66e93e8505a2e: __construct closable_66e93e8505a4e: __construct closable_66e93e8505a51: __construct a() start closable_66e93e8505a55: __construct a() end b() start closable_66e93e8505a5a: __construct b() catch b() finally closable_66e93e8505a5a: close closable_66e93e8505a5a: open a() start closable_66e93e8505a74: __construct a() end b() start closable_66e93e8505a79: __construct b() catch b() finally closable_66e93e8505a79: close closable_66e93e8505a79: open a() start closable_66e93e8505a88: __construct a() end b() start closable_66e93e8505a8d: __construct b() catch b() finally closable_66e93e8505a8d: close closable_66e93e8505a8d: open a() start closable_66e93e8505a9c: __construct a() end b() start closable_66e93e8505aa0: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8505aaf: __construct a() end b() start closable_66e93e8505ab4: __construct b() catch b() finally closable_66e93e8505ab4: close closable_66e93e8505ab4: open a() start closable_66e93e8505abe: __construct a() end b() start closable_66e93e8505ac2: __construct b() catch b() finally closable_66e93e8505ac2: close closable_66e93e8505ac2: open a() start closable_66e93e8505acc: __construct a() end b() start closable_66e93e8505ad0: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8505ad6: __construct a() end b() start closable_66e93e8505ada: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59 a() start closable_66e93e8505ae0: __construct a() end b() start closable_66e93e8505ae4: __construct b() catch b() finally closable_66e93e8505ae4: close closable_66e93e8505ae4: open a() start closable_66e93e8505aee: __construct a() end b() start closable_66e93e8505af3: __construct b() catch b() finally closable_66e93e8505af3: close closable_66e93e8505af3: open a() start closable_66e93e8505b02: __construct a() end b() start closable_66e93e8505b08: __construct b() return b() finally Warning: Undefined variable $b in /in/tkFYi on line 59

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
31.51 ms | 422 KiB | 5 Q