3v4l.org

run code in 500+ PHP versions simultaneously
<?php $falses = [ 'aFalseBool' => false, 'aFalseString' => 'false', 'aNull' => null, 'zero' => 0, 'emptyString' => '', ]; $truths = [ 'aTrueBool' => true, 'aTrueString' => 'true', 'non-zero' => 42, 'anyString' => 'anystring', ]; echo "These should be false:" . PHP_EOL; foreach($falses as $key => $item) { if ((bool) $item === false) { printf("%s is false\n", $key); } else { printf("%s is not false\n", $key); } } echo "These should be true:" . PHP_EOL; foreach($truths as $key => $item) { if ((bool) $item === true) { printf("%s is true\n", $key); } else { printf("%s is not true\n", $key); } }

preferences:
60.37 ms | 2769 KiB | 5 Q