Jump to content

True and false OR 1 and 0?


Eiolon

Recommended Posts

really depends on what it is that you are trying to receive a true false response on.. if it is a boolean function.. then it will return TRUE or FALSE upon execution.. if it is a custom function, or something along those lines.. a 0 or 1 is viable..

An integer 0 (zero) or a boolean FALSE will evaluate to FALSE using both strict === and loose == comparisons. An integer 1 (one) will only evaluate to TRUE with a loose == comparison. Run the code below . . .

 

$vars = array('zero' => 0, 'one' => 1, 'true' => TRUE, 'false' => FALSE);
foreach( $vars as $k => $v ) {
echo "<br>Key: $k <=> var_dump: ";
var_dump($v);
echo '<br>';
echo "Loose == comparison to TRUE: ";
echo $v == TRUE ? 'Yes<br>' : 'No<br>';
echo "Strict === comparison to TRUE: ";
echo $v === TRUE ? 'Yes<br>' : 'No<br>';
echo "Loose == comparison to FALSE: ";
echo $v == FALSE ? 'Yes<br>' : 'No<br>';
echo "Strict === comparison to FALSE: ";
echo $v == FALSE ? 'Yes<br>' : 'No<br>';
echo '<hr>';
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.