Home > Article > Backend Development > Detailed explanation of Boolean variables of PHP data types
Boolean is the simplest type. Boolean expresses truth and falsehood, and can be True or False. To specify a variable as a Boolean value, use the keyword True or False, both of which are case-insensitive, as shown below:
$flag=TRUE;//Assign TRUE to the variable $flag
?>
Boolean types are mostly used to control processes. When comparing two objects, you can use "==" to determine whether it is true. In addition, when using Boolean variables for process control, you can use them directly without comparing with the true keyword, as shown in Program 2-4. Show.
$action="show_book";
$show_br=true;
//Use "==" to judge
//Return Boolean type, used for if conditional branch judgment
if($action=="show_version "){
echo "You have chosen to display the current version number! ";
}
//The following code is no longer needed
if($show_br==true){
echo "
n";
}
//Use a simplified judgment method
if($show_br){
echo "
n";
}
?>
The above is the detailed explanation of Boolean variables of PHP data types, more related content Please pay attention to the PHP Chinese website (www.php.cn)!