3v4l.org

run code in 300+ PHP versions simultaneously
<?php foreach (['', null, 0, 0.0, '0', false, [], new stdClass, 'foo', 1, true, ['bar' => 'baz']] as $val) { var_dump($val, count($val), !empty($val)); echo '-------------', PHP_EOL; } var_dump('undefined', count($undefined), !empty($undefined));
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0
Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/SdPPI:4 Stack trace: #0 {main} thrown in /in/SdPPI on line 4
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.0.0 - 8.0.9
Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, string given in /in/SdPPI:4 Stack trace: #0 {main} thrown in /in/SdPPI on line 4
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.3.33, 7.4.0 - 7.4.25, 7.4.27 - 7.4.33
Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 string(0) "" int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 NULL int(0) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 int(0) int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 float(0) int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 string(1) "0" int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 bool(false) int(1) bool(false) ------------- array(0) { } int(0) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 object(stdClass)#1 (0) { } int(1) bool(true) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 string(3) "foo" int(1) bool(true) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 int(1) int(1) bool(true) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 bool(true) int(1) bool(true) ------------- array(1) { ["bar"]=> string(3) "baz" } int(1) bool(true) ------------- Notice: Undefined variable: undefined in /in/SdPPI on line 8 Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 8 string(9) "undefined" int(0) bool(false)
Output for 7.3.32, 7.4.26
Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 string(0) "" int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 NULL int(0) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 int(0) int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 float(0) int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 string(1) "0" int(1) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 bool(false) int(1) bool(false) ------------- array(0) { } int(0) bool(false) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 object(stdClass)#1 (0) { } int(1) bool(true) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 string(3) "foo" int(1) bool(true) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 int(1) int(1) bool(true) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 4 bool(true) int(1) bool(true) ------------- array(1) { ["bar"]=> string(3) "baz" } int(1) bool(true) ------------- Warning: count(): Parameter must be an array or an object that implements Countable in /in/SdPPI on line 8 string(9) "undefined" int(0) bool(false)
Output for 7.1.0 - 7.1.33
string(0) "" int(1) bool(false) ------------- NULL int(0) bool(false) ------------- int(0) int(1) bool(false) ------------- float(0) int(1) bool(false) ------------- string(1) "0" int(1) bool(false) ------------- bool(false) int(1) bool(false) ------------- array(0) { } int(0) bool(false) ------------- object(stdClass)#1 (0) { } int(1) bool(true) ------------- string(3) "foo" int(1) bool(true) ------------- int(1) int(1) bool(true) ------------- bool(true) int(1) bool(true) ------------- array(1) { ["bar"]=> string(3) "baz" } int(1) bool(true) ------------- Notice: Undefined variable: undefined in /in/SdPPI on line 8 string(9) "undefined" int(0) bool(false)

preferences:
201.44 ms | 418 KiB | 5 Q