3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Foo { case Bar; private function &getState(): array { static $state = []; return $state; } public function increment(): void { $this->getState()[$this->name]['count'] ??= 0; ++$this->getState()[$this->name]['count']; } public function getCount(): int { return $this->getState()[$this->name]['count'] ?? 0; } } Foo::Bar->increment(); var_dump( Foo::Bar->getCount());
Output for git.master, git.master_jit
int(1)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
41.22 ms | 405 KiB | 5 Q