3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $values = array( 'bool_f' => false, 'bool_t' => true, 'string_empty' => '', 'string_bool_f' => 'false', 'string_bool_t' => 'true', 'int_0' => 0, 'int_1' => 1, 'int_neg' => -100, 'int_norm' => 100, 'array_empty' => array(), 'array_null_val' => array(null), 'obj_empty' => new stdClass(), ); $mask = "%-15.15s %7.7s\n"; // Print header printf($mask, 'Name', 'Empty'); echo PHP_EOL; foreach ($values as $name => $val) { $empty = empty($val) ? 'true' : 'false'; printf($mask, $name, $empty); }
Output for 5.0.2 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Name Empty bool_f true bool_t false string_empty true string_bool_f false string_bool_t false int_0 true int_1 false int_neg false int_norm false array_empty true array_null_val false obj_empty false
Output for 5.0.0 - 5.0.1
Name Empty Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/kH3X3 on line 22 PHP_EOLbool_f true bool_t false string_empty true string_bool_f false string_bool_t false int_0 true int_1 false int_neg false int_norm false array_empty true array_null_val false obj_empty false
Output for 4.3.10 - 4.4.9
Name Empty bool_f true bool_t false string_empty true string_bool_f false string_bool_t false int_0 true int_1 false int_neg false int_norm false array_empty true array_null_val false obj_empty true
Output for 4.3.0 - 4.3.9
Name Empty Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/kH3X3 on line 22 PHP_EOLbool_f true bool_t false string_empty true string_bool_f false string_bool_t false int_0 true int_1 false int_neg false int_norm false array_empty true array_null_val false obj_empty true