Uppercase Booleans vs. Lowercase in PHP
Last Updated :
11 Feb, 2019
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.
<?php
$boolean = TRUE;
echo $boolean . "\n" ;
$boolean = true;
echo $boolean ;
?>
|
Example: This example compare the uppercase and lowercase boolean value.
<?php
$var1 = TRUE;
$var2 = true;
if ( $var1 == $var2 )
echo "TRUE and true both are same \n" ;
else
echo "TRUE and true both are different \n" ;
$var1 = FALSE;
$var2 = false;
if ( $var1 == $var2 )
echo "FALSE and false both are same \n" ;
else
echo "FALSE and false both are different \n" ;
?>
|
Output:
TRUE and true both are same
FALSE and false both are same
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...