3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface proxy {} trait assertFinal { private function assertFinal() { if (is_subclass_of($this, __CLASS__, false) && !$this instanceof proxy) { trigger_error('Nein! Class is final!', E_USER_NOTICE); } } } class finalfoo { use assertFinal; public function __construct() { $this->assertFinal(); } } class fooproxy extends finalfoo implements proxy { } class naughtyfoo extends finalfoo { } echo "new finalfoo: "; try {new finalfoo; echo "yes";} catch (\Exception $e) { echo "no"; } echo "\n"; echo "new fooproxy: "; try {new fooproxy; echo "yes";} catch (\Exception $e) { echo "no"; } echo "\n"; echo "new naughtyfoo: "; try {new naughtyfoo; echo "yes";} catch (\Exception $e) { echo "no"; } echo "\n";
Output for git.master, git.master_jit, rfc.property-hooks
new finalfoo: yes new fooproxy: yes new naughtyfoo: Notice: Nein! Class is final! in /in/HUYkX on line 10 yes

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:
45.84 ms | 401 KiB | 8 Q