3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(-1); var_dump(count(array())); var_dump(count(0)); var_dump(count(42)); var_dump(count("")); var_dump(count("Hello World")); var_dump(count(new stdClass)); class Test {} var_dump(count(new Test)); var_dump(count($non_existent_variable)); var_dump(count(null));
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
int(0) Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /in/7lEGR:6 Stack trace: #0 {main} thrown in /in/7lEGR on line 6
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 int(0) Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, int given in /in/7lEGR:6 Stack trace: #0 {main} thrown in /in/7lEGR on line 6
Process exited with code 255.
Output for 8.0.0 - 8.0.9
int(0) Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, int given in /in/7lEGR:6 Stack trace: #0 {main} thrown in /in/7lEGR on line 6
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
int(0) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 6 int(1) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 7 int(1) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 8 int(1) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 9 int(1) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 10 int(1) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 12 int(1) Notice: Undefined variable: non_existent_variable in /in/7lEGR on line 13 Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 13 int(0) Warning: count(): Parameter must be an array or an object that implements Countable in /in/7lEGR on line 14 int(0)
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
int(0) int(1) int(1) int(1) int(1) int(1) int(1) Notice: Undefined variable: non_existent_variable in /in/7lEGR on line 13 int(0) int(0)

preferences:
183.09 ms | 402 KiB | 185 Q