3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private function &getState(): array { static $state = ['counter' => 0]; return $state; } public function count(): int { return $this->getState()['counter']++; } } $x = new Foo(); $y = new Foo(); var_dump($x->count(), $y->count());;

This is an error 500

Value for `_results` contains invalid data `array`


preferences:
156.54 ms | 1455 KiB | 9 Q