3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class SuperAbstract { static function create() { return new static(); } } class Extended extends SuperAbstract { private $hello = ''; protected function __construct() { $this->hello = "world"; } public function hello() { return "hello " . $this->hello; } } // works $a = Extended::create(); echo $a->hello(); echo "\n\nNow we'll fail, trying to call 'new' directly:\n"; // can't touch this $b = new Extended();
Output for git.master, git.master_jit, rfc.property-hooks
hello world Now we'll fail, trying to call 'new' directly: Fatal error: Uncaught Error: Call to protected Extended::__construct() from global scope in /in/LliKj:30 Stack trace: #0 {main} thrown in /in/LliKj on line 30
Process exited with code 255.

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:
176.38 ms | 405 KiB | 5 Q