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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
Setting $prop: 42 object(C)#1 (1) { ["prop":"C":private]=> &int(43) }

preferences:
81.62 ms | 406 KiB | 5 Q