3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private static $_count = 0; private $_number; function __construct() { $this->_number = ++static::$_count; } public function __toString(){ return static::$_count . ' | ' . $this->_number . "\n"; } public function __invoke(){ return $this->_number; } } class B { private $_status = C::newInstance; public function show (){echo $this->_status;} } class C { private $message; public function __construct($message){ $this->message = $message; } public static function newInstance($message){ return new C($message); } public function __toString(){ return $this->message . " | "; } } $_b = new B(); $_b->show(); $a = new A(); $b = new A(); $c = new A(); $d = new A(); echo $a, $b, $c, $d; echo $a(), $b(), $c(), $d();
Output for git.master, git.master_jit
Fatal error: Uncaught Error: Undefined constant C::newInstance in /in/9KiD0:19 Stack trace: #0 {main} thrown in /in/9KiD0 on line 19
Process exited with code 255.
Output for rfc.property-hooks
Fatal error: Uncaught Error: Undefined constant C::newInstance in /in/9KiD0:19 Stack trace: #0 /in/9KiD0(39): [constant expression]() #1 {main} thrown in /in/9KiD0 on line 19
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:
38.33 ms | 401 KiB | 8 Q