In PHP we have different kinds of data types such as integers, float, character, double and so on. There are one logical data type which is called Boolean data type. It is a primitive data type having either true or false values.
In PHP we have different kinds of data types such as integers, float, character, double and so on. There are one logical data type which is called Boolean data type. It is a primitive data type having either true or false values.PHP Variables Boolean
In PHP we have different kinds of data types such as integers, float, character, double and so on. There are one logical data type which is called Boolean data type. It is a primitive data type having either true or false values. This is the simplest data type that expresses only truth value. It is introduced in PHP 4 and other programming languages using Boolean in different way. For example :
<?php
$age = true; //assign the value true or false.
$costs = 100;
if($age==18) //comparison of Boolean Value
{
$costs = 200;
}
echo "The Entry Price is"." ". $costs;
?>
The output is : The Entry Price is 200.
Here, in this example we assign the value of true and then compare with the condition. If the age is equals to 18 then print its revised amount. Sometime the only the if condition doesn't full fill our requirement. So, for this purpose we also use else if or else condition to full fill our need For example :
<?php
$age = true;
$costs = 300;
if($age!=18)
{
$discount = 2;
echo "You have got the special Discount on 31st december & your costs is". " ".$costs/$discount;
}
else
{
echo "SORRY!! Do not qualify for the Discount because you are above 18! and your costs is"." ".$costs;
}
?>
The output is : You have got the special discount on 31st December & your costs is 150.