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 ? 'already closed' : 'closing'); $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_66f324b408fb2: __construct closable_66f324b408fe6: __construct closable_66f324b408fef: __construct a() start closable_66f324b408ff8: __construct a() end b() start closable_66f324b409003: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b409036: __construct a() end b() start closable_66f324b409041: __construct b() catch b() finally closable_66f324b409041: close closable_66f324b409041: closing a() start closable_66f324b409076: __construct a() end b() start closable_66f324b409082: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b409094: __construct a() end b() start closable_66f324b4090a1: __construct b() catch b() finally closable_66f324b4090a1: close closable_66f324b4090a1: closing a() start closable_66f324b4090bf: __construct a() end b() start closable_66f324b4090ca: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b4090da: __construct a() end b() start closable_66f324b4090e6: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b4090f5: __construct a() end b() start closable_66f324b4090ff: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b40910e: __construct a() end b() start closable_66f324b409119: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b409128: __construct a() end b() start closable_66f324b409133: __construct b() catch b() finally closable_66f324b409133: close closable_66f324b409133: closing a() start closable_66f324b40914f: __construct a() end b() start closable_66f324b40915a: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b409169: __construct a() end b() start closable_66f324b409174: __construct b() catch b() finally closable_66f324b409174: close closable_66f324b409174: closing
Output for git.master
closable_66f324b402698: __construct closable_66f324b402718: __construct closable_66f324b402724: __construct a() start closable_66f324b402733: __construct a() end b() start closable_66f324b402742: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b402774: __construct a() end b() start closable_66f324b402783: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b40279a: __construct a() end b() start closable_66f324b4027aa: __construct b() catch b() finally closable_66f324b4027aa: close closable_66f324b4027aa: closing a() start closable_66f324b4027db: __construct a() end b() start closable_66f324b4027e9: __construct b() catch b() finally closable_66f324b4027e9: close closable_66f324b4027e9: closing a() start closable_66f324b402814: __construct a() end b() start closable_66f324b402823: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b402839: __construct a() end b() start closable_66f324b402848: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b40285b: __construct a() end b() start closable_66f324b40286b: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b402882: __construct a() end b() start closable_66f324b40288f: __construct b() catch b() finally closable_66f324b40288f: close closable_66f324b40288f: closing a() start closable_66f324b4028ab: __construct a() end b() start closable_66f324b4028b6: __construct b() catch b() finally closable_66f324b4028b6: close closable_66f324b4028b6: closing a() start closable_66f324b4028dc: __construct a() end b() start closable_66f324b4028eb: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b4028fd: __construct a() end b() start closable_66f324b402908: __construct b() catch b() finally closable_66f324b402908: close closable_66f324b402908: closing
Output for rfc.property-hooks
closable_66f324b4080a8: __construct closable_66f324b40812c: __construct closable_66f324b408137: __construct a() start closable_66f324b408141: __construct a() end b() start closable_66f324b40814c: __construct b() catch b() finally closable_66f324b40814c: close closable_66f324b40814c: closing a() start closable_66f324b408186: __construct a() end b() start closable_66f324b408191: __construct b() catch b() finally closable_66f324b408191: close closable_66f324b408191: closing a() start closable_66f324b4081af: __construct a() end b() start closable_66f324b4081bb: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b4081d7: __construct a() end b() start closable_66f324b4081e3: __construct b() catch b() finally closable_66f324b4081e3: close closable_66f324b4081e3: closing a() start closable_66f324b4081ff: __construct a() end b() start closable_66f324b40821c: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b40822e: __construct a() end b() start closable_66f324b408238: __construct b() catch b() finally closable_66f324b408238: close closable_66f324b408238: closing a() start closable_66f324b408254: __construct a() end b() start closable_66f324b40825f: __construct b() catch b() finally closable_66f324b40825f: close closable_66f324b40825f: closing a() start closable_66f324b40827a: __construct a() end b() start closable_66f324b408285: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b408296: __construct a() end b() start closable_66f324b4082a1: __construct b() return b() finally Warning: Undefined variable $b in /in/hK5tK on line 59 a() start closable_66f324b4082b0: __construct a() end b() start closable_66f324b4082bb: __construct b() catch b() finally closable_66f324b4082bb: close closable_66f324b4082bb: closing a() start closable_66f324b4082d7: __construct a() end b() start closable_66f324b4082e2: __construct b() catch b() finally closable_66f324b4082e2: close closable_66f324b4082e2: closing

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:
26.26 ms | 423 KiB | 5 Q