3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $bar; } $foo = new Foo; $arr = 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" ); define('PAD', array_map('strlen', $arr)); $headings = array('type', 'if', 'isset', 'empty', 'is_null'); // foreach($headings as $heading){ echo str_pad($heading, PAD), " | "; } echo "\n"; $x = str_pad("TRUE", PAD) . " | "; $y = str_pad("", PAD) . " | "; foreach($arr as $key => $val){ echo str_pad($key, PAD), " | "; echo $val ? $x : $y; echo isset($val) ? $x : $y; echo empty($val) ? $x : $y; echo is_null($val) ? $x : $y; echo "\n"; }
based on gsq64
Output for 7.0.0 - 7.2.0
Warning: strlen() expects parameter 1 to be string, array given in /in/qRYJ7 on line 20 Warning: strlen() expects parameter 1 to be string, object given in /in/qRYJ7 on line 20 Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 25 Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 26 Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | | Warning: str_pad() expects parameter 2 to be integer, array given in /in/qRYJ7 on line 29 | | | | |
Output for 5.3.19 - 5.6.28
Warning: strlen() expects parameter 1 to be string, array given in /in/qRYJ7 on line 20 Warning: strlen() expects parameter 1 to be string, object given in /in/qRYJ7 on line 20 Warning: Constants may only evaluate to scalar values in /in/qRYJ7 on line 20 Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 25 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 25 Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 26 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 26 Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | | Notice: Use of undefined constant PAD - assumed 'PAD' in /in/qRYJ7 on line 29 Warning: str_pad() expects parameter 2 to be long, string given in /in/qRYJ7 on line 29 | | | | |