3v4l.org

run code in 300+ PHP versions simultaneously
<?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"; } */
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
Fatal error: Uncaught DivisionByZeroError: Division by zero in /in/P2NLC:30 Stack trace: #0 {main} thrown in /in/P2NLC on line 30
Process exited with code 255.
Output for 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
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 7.3.32 - 7.3.33
Warning: Division by zero in /in/P2NLC on line 30 type|if |isset |empty |is_null |
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
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 |

preferences:
281.26 ms | 402 KiB | 378 Q