Home > Backend Development > PHP Tutorial > Detailed explanation of Boolean variables of PHP data types

Detailed explanation of Boolean variables of PHP data types

黄舟
Release: 2023-03-03 21:12:01
Original
2880 people have browsed it

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 (m.sbmmt.com)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template