3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { private $prop; public function &getProp() { return $this->prop; } public function setProp($value) { echo "Setting \$prop: $value\n"; $this->prop = $value; } } $c = new C(); $c->setProp(42); $prop = &$c->getProp(); $prop++; var_dump($c);
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Setting $prop: 42 object(C)#1 (1) { ["prop":"C":private]=> &int(43) }

preferences:
88.09 ms | 402 KiB | 62 Q