Friday, January 14, 2011

Boolean Values-PHP-

say with me....1,2,3:BOOOOOLEANN!!hahaha

Oke ,it is known as True or False values. True = 1, and False =0. Let we just jump to example !


<?php
$true_value = true;
$false_value = false;


print ("true_value = " . $true_value);
 

print (" false_value = " . $false_value);
?>

OK ,for this script it will show to u the value of true and false,for false,it will print blank NOT the number zero.Another example for proving that true=1 and false=0:

<?php
$true_value = true;
$false_value = false;


if ($true_value == 1) 
{
print("that's true");
}


else

{
print (" false_value = " . $false_value);
 }

?>

Plus,u also can do like this:
<?php
$true_value = true;
$false_value = false;


if ($true_value) 
{
print("that's true");
}


else

{

print (" false_value = " . $false_value);
 }

?>
Besides,NOT also can use with boolean value,like this:


$true_value = true;

if (!$true_value) {
print("that's true");
}
 

else {
print("that's not true");
}



N/NOTE:try it,test it!!god luck!

No comments:

Post a Comment