3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $bar; } $foo = new Foo; $blanks = array("", " ", FALSE, TRUE, array(), NULL, "0", 0, 0.0, new stdClass, $foo->bar, "\0"); foreach($blanks as $blank){ var_dump($blank); $type = gettype($blank); if(count($blank) == 0){ $val = "empty"; } echo "$type($val)\n"; }
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.6
string(0) "" Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /in/j24Rf:11 Stack trace: #0 {main} thrown in /in/j24Rf on line 11
Process exited with code 255.
Output for 8.0.0 - 8.0.9
string(0) "" Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, string given in /in/j24Rf:11 Stack trace: #0 {main} thrown in /in/j24Rf on line 11
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
string(0) "" Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 Notice: Undefined variable: val in /in/j24Rf on line 12 string() string(1) " " Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 Notice: Undefined variable: val in /in/j24Rf on line 12 string() bool(false) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 Notice: Undefined variable: val in /in/j24Rf on line 12 boolean() bool(true) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 Notice: Undefined variable: val in /in/j24Rf on line 12 boolean() array(0) { } array(empty) NULL Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 NULL(empty) string(1) "0" Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 string(empty) int(0) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 integer(empty) float(0) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 double(empty) object(stdClass)#2 (0) { } Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 object(empty) NULL Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 NULL(empty) string(1) "" Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 string(empty)
Output for 7.3.32 - 7.3.33
string(0) "" Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 string() string(1) " " Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 string() bool(false) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 boolean() bool(true) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 boolean() array(0) { } array(empty) NULL Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 NULL(empty) string(1) "0" Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 string(empty) int(0) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 integer(empty) float(0) Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 double(empty) object(stdClass)#2 (0) { } Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 object(empty) NULL Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 NULL(empty) string(1) "" Warning: count(): Parameter must be an array or an object that implements Countable in /in/j24Rf on line 11 string(empty)
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33
string(0) "" Notice: Undefined variable: val in /in/j24Rf on line 12 string() string(1) " " Notice: Undefined variable: val in /in/j24Rf on line 12 string() bool(false) Notice: Undefined variable: val in /in/j24Rf on line 12 boolean() bool(true) Notice: Undefined variable: val in /in/j24Rf on line 12 boolean() array(0) { } array(empty) NULL NULL(empty) string(1) "0" string(empty) int(0) integer(empty) float(0) double(empty) object(stdClass)#2 (0) { } object(empty) NULL NULL(empty) string(1) "" string(empty)

preferences:
276.23 ms | 404 KiB | 375 Q