Simple Truthy Check
PHP
Easy
5 views
Problem Description
Input is one token. Treat '', '0', and 'false' (case-insensitive) as false, everything else as true. Print TRUE or FALSE.
Input Format
One token s.
Output Format
TRUE or FALSE.
Official Solution
<?php
$inputText=trim(stream_get_contents(STDIN));
if($inputText==='') { echo 'FALSE'; exit; }
$low=strtolower($inputText);
if($low==='0' || $low==='false') echo 'FALSE'; else echo 'TRUE';
?>
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!