3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $prop = 0; public function &getPropRef () { return (int)$this->prop; } } $obj = new Foo(); $variable = &$obj->getPropRef(); $variable = 1; $variable = 2; $variable = 3; echo $obj->prop;
Output for 8.1.27 - 8.1.33, 8.2.14 - 8.2.29, 8.3.1 - 8.3.25, 8.4.1 - 8.4.12
Notice: Only variable references should be returned by reference in /in/I4KcF on line 7 0

preferences:
66.51 ms | 406 KiB | 5 Q