- var_dump: documentation ( source)
<?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);