3v4l.org

run code in 500+ 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.0 - 8.2.34, 8.3.0 - 8.3.35, 8.4.1 - 8.4.26, 8.5.0 - 8.5.11
3
Output for 5.0.0
Strict Standards: Only variable references should be returned by reference in /in/HPlJT on line 7 0

preferences:
30.1 ms | 1139 KiB | 8 Q