Convert phpboolfalse to 0: home. phpchina. comspace. php? Uid108724 & amp; doblog & amp; id54899PHP is a loose language, which means that the Boolean value false and integer value 0 are treated as the same (even c regards 0 and false as the equivalent value ). You can use the script to determine 0 and php bool false and the value 0.
Turn: http://home.phpchina.com/space.php? Uid = 108724 & do = blog & id = 54899
PHP is a loose language, which means that Boolean values false and integer values 0 are considered the same (even c treats 0 and false as equivalent ). Can I use a script to determine the values of 0 and boolean? The equivalence of false:
?
? $ Test_var = 0;
? If ($ test_var = false ){
?? Echo "yes ";
?} Else {
?? Echo "no ";
?}
?>?
?
Output: yes
?
_________________________________________________________________________________
?
? $ Test_var = 0;
? If ($ test_var! = False ){
?? Echo "yes ";
?} Else {
?? Echo "no ";
?}
?>
?
Output: yes
?
_________________________________________________________________
?
The problem is that the Boolean value false is obviously different from the integer value 0.
?
?
PHP has a gettype () function to obtain the variable type. You can use the = operator (after reading it, there are three equal signs ). The difference between the = operator and the = operator is that the operator is bothCompare data values and types.
?
When different variable types are involved in the conditions for termination, use? ===And ?! = It is very important to perform a strong type check for operators.
?