Uppercase Booleans vs. Lowercase in PHP

The boolean expresses the truth value. The Boolean represents two possible values: TRUE or FALSE. True can be given a value of 1, and False is given a value of zero.

To specify a boolean literal, use the constants TRUE or FALSE. Both are case-insensitive. It means that TRUE is equal to true and FALSE is equal to false. So it can be written as

true === TRUE and false === FALSE

Example 1: This example display the value of uppercase and lowercase boolean.



filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to illustrates
// boolean value
  
// Declare a variable and initialize it
$boolean = TRUE;
  
// Display the value of variable
echo $boolean . "\n";
  
// Declare a variable and initialize it
$boolean = true;
  
// Display the value of variable
echo $boolean;
  
?>

chevron_right


Output:

1
1

Example: This example compare the uppercase and lowercase boolean value.

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
// PHP program to illustrates
// boolean value
  
// Declare a variable and initialize it
$var1 = TRUE;
$var2 = true;
  
// Check both boolean value is same or not
if($var1 == $var2)
    echo "TRUE and true both are same \n";
else
    echo "TRUE and true both are different \n";
  
// Declare a variable and initialize it
$var1 = FALSE;
$var2 = false;
  
// Check both boolean value is same or not
if($var1 == $var2)
    echo "FALSE and false both are same \n";
else
    echo "FALSE and false both are different \n";
?>

chevron_right


Output:

TRUE and true both are same 
FALSE and false both are same


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.