3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Something { public function one(): int { global $number; if ($number === null) $number = 1; return $number; } public function two(): int { global $number; if ($number === null) $number = 2; return $number; } } $s = new Something(); var_dump($s->one()); var_dump($s->two());
Output for 7.4.0 - 7.4.27, 8.0.0 - 8.0.14, 8.1.0 - 8.1.2
int(1) int(1)

preferences:
33.37 ms | 459 KiB | 5 Q