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); switch($blank){ case 0: $val = "empty"; break; } echo "$type($val)\n"; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
string(0) "" Warning: Undefined variable $val in /in/fUUgk on line 15 string() string(1) " " Warning: Undefined variable $val in /in/fUUgk on line 15 string() bool(false) boolean(empty) bool(true) boolean(empty) array(0) { } array(empty) NULL NULL(empty) string(1) "0" string(empty) int(0) integer(empty) float(0) double(empty) object(stdClass)#2 (0) { } Notice: Object of class stdClass could not be converted to int in /in/fUUgk on line 12 object(empty) NULL NULL(empty) string(1) "" string(empty)
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
string(0) "" string(empty) string(1) " " string(empty) bool(false) boolean(empty) bool(true) boolean(empty) array(0) { } array(empty) NULL NULL(empty) string(1) "0" string(empty) int(0) integer(empty) float(0) double(empty) object(stdClass)#2 (0) { } Notice: Object of class stdClass could not be converted to int in /in/fUUgk on line 12 object(empty) NULL NULL(empty) string(1) "" string(empty)
Output for 7.3.32 - 7.3.33
string(0) "" string(empty) string(1) " " string(empty) bool(false) boolean(empty) bool(true) boolean(empty) 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:
239.34 ms | 402 KiB | 369 Q