3v4l.org

run code in 500+ 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.34, 8.2.0 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.13, 8.6.0
Notice: Only variable references should be returned by reference in /in/I4KcF on line 7 0

preferences:
28.26 ms | 1164 KiB | 6 Q