3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { public $value = []; public function &getValue() { return $this->value; } } $obj = new foo; $myValue = &$obj->getValue(); // $myValue is a reference to $obj->value, which is 42. $myValue[] = 123; var_dump($obj->value);

preferences:
39.46 ms | 402 KiB | 5 Q