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..

Link to comment
Share on other sites

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>';
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.