ryoakg
5/18/2016 - 11:25 PM

falsey-values.php

<?php
// cf. http://php.net/manual/en/types.comparisons.php
//     http://stackoverflow.com/questions/137487/null-vs-false-vs-0-in-php
function test($x){
    return [$x ? 1 : 2,
            $x == false ? 1 : 2,
            $x === false ? 1 : 2,
            (bool)empty($x)];
}