3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $bar; } $foo = new Foo; $blanks = array( "string(empty) \"\"" => "", "string(space) \" \"" => " ", "bool(false)" => FALSE, "bool(true)" => TRUE, "array(empty) {}" => array(), "NULL" => NULL, "string(\"zero\") \"0\"" => "0", "int(0)" => 0, "float(0.0)" => 0.0, "object(stdClass)# (empty) {}" => new stdClass, "public \$bar" => $foo->bar, "string(null byte) \"\\0\"" => "\0" ); $headings = array('type', 'if', 'isset', 'empty', 'is_null'); foreach(array($headings, array_keys($blanks)) as $ord => $arr){ foreach($arr as $val){ static $max = 0; if(strlen($val) > $max){ $max = strlen($val); } } ${"pad_$ord"} = $max; } for($i = 0; $i < count($headings); $i++){ echo str_pad($headings[$i], ${'pad_' . ($i/$i)}), "|"; } /* $x = str_pad("TRUE", PAD_1) . " | "; $y = str_pad("", PAD_1) . " | "; foreach($arr as $key => $val){ echo str_pad($key, max(array_map('strlen', array_keys($arr)))), " | "; echo $val ? $x : $y; echo isset($val) ? $x : $y; echo empty($val) ? $x : $y; echo is_null($val) ? $x : $y; echo "\n"; } */
based on 1M68S
Output for 7.0.0 - 7.2.0
Warning: Division by zero in /in/P2NLC on line 30 Notice: Undefined variable: pad_NAN in /in/P2NLC on line 30 type|if |isset |empty |is_null |
Output for 5.3.19 - 5.6.28
Warning: Division by zero in /in/P2NLC on line 30 Notice: Undefined variable: pad_ in /in/P2NLC on line 30 type|if |isset |empty |is_null |