3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FizzBuzz { public function __call($n, $args) { return [0b10=>@Fizz,0b01=>@Buzz,0b11=>@FizzBuzz][(!($n%3)<<1)|!($n%5)]??$n; } } $fb = new FizzBuzz; var_dump($fb->{"0"}()); var_dump($fb->{"1"}()); var_dump($fb->{"2"}()); var_dump($fb->{"3"}()); var_dump($fb->{"4"}()); var_dump($fb->{"5"}()); var_dump($fb->{"6"}()); var_dump($fb->{"7"}()); var_dump($fb->{"8"}()); var_dump($fb->{"9"}()); var_dump($fb->{"10"}());
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
Fatal error: Uncaught Error: Undefined constant "Fizz" in /in/l4F8j:7 Stack trace: #0 /in/l4F8j(12): FizzBuzz->__call('0', Array) #1 {main} thrown in /in/l4F8j on line 7
Process exited with code 255.
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Fatal error: Uncaught Error: Undefined constant "Fizz" in /in/l4F8j:7 Stack trace: #0 /in/l4F8j(12): FizzBuzz->__call('0', Array) #1 {main} thrown in /in/l4F8j on line 7
Process exited with code 255.
Output for 7.1.25 - 7.1.32, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
string(8) "FizzBuzz" string(1) "1" string(1) "2" string(4) "Fizz" string(1) "4" string(4) "Buzz" string(4) "Fizz" string(1) "7" string(1) "8" string(4) "Fizz" string(4) "Buzz"

preferences:
153.52 ms | 402 KiB | 176 Q