- var_dump: documentation ( source)
<?php
class foo {
public $bar = null;
public function &getBar() {
if ($this->bar === null) {
$this->bar[] = 'init';
}
return $this->bar;
}
}
$obj = new foo;
$myValue = &$obj->getBar();
$myValue[] = 123;
var_dump($obj->bar);