PHP/Data Type/boolean
Содержание
Boolean type constant: FALSE
<?
if (FALSE)
print("This will never print<BR>");
else
print("This will always print<BR>");
?>
Boolean values
<?
$a=100;
if($a==100) {
echo "the variable equals 1!<br>";
}
if($a==true) {
echo "the variable is true!<br>";
}
?>
Converting from a boolean to a string will produce a 1 if the boolean is set to true, or an empty string if false.
<?
$bool = true;
print "Bool is set to $bool\n";
$bool = false;
print "Bool is set to $bool\n";
?>
PHP provides a couple of constants especially for use as Booleans: TRUE and FALSE
<?
if (TRUE)
print("This will always print<BR>");
else
print("This will never print<BR>");
?>