3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyObject{ public static $_register = array(); public $_id = -1; public $_value = ''; function __construct( $value ){ $this->_value = $value; $this->_id = count( self::$_register ); var_dump($this); self::$_register[ $this->_id ] = &$this; // I also tried '= &$this' } function foo(){ // outputs 'id : value' echo $this->_id.' : ' . $this->_value. PHP_EOL; } } $test = new MyObject( 'hihi' ); $test->foo(); var_dump(MyObject::$_register); MyObject::$_register[0]->_value='bar'; var_dump(MyObject::$_register);
Output for git.master, git.master_jit, rfc.property-hooks
object(MyObject)#1 (2) { ["_id"]=> int(0) ["_value"]=> string(4) "hihi" } 0 : hihi array(1) { [0]=> object(MyObject)#1 (2) { ["_id"]=> int(0) ["_value"]=> string(4) "hihi" } } array(1) { [0]=> object(MyObject)#1 (2) { ["_id"]=> int(0) ["_value"]=> string(3) "bar" } }

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