3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"; }
based on fUUgk
Output for 7.2.0
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 5.3.19 - 7.1.10
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)