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());;

preferences:
23.4 ms | 404 KiB | 5 Q