3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $prop = 0; public function &getPropRef () { return ($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.14 - 8.2.30, 8.3.1 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
3
Output for 5.0.0
Strict Standards: Only variable references should be returned by reference in /in/HPlJT on line 7 0

preferences:
59.81 ms | 813 KiB | 4 Q