PHP Support conditional statements like if and if..else statements.in this topic we discuss on simple if and if..else statements the following syntax and example of both type.
Use the if statements to execute some code only if specified condition is true.the following syntax and example of if.
<?php
if(condition)
{
//Code to be Executed if Condition is True
}
?>
<?php
$a=10;
if($a<10)
{
echo "The Value is Less Than 10";
}
?>
Use the if..else statement to execute some code if a condition is true and another code if condition is false.the following syntax and example of if..else.
<?php
if(condition)
{
//Code to be Executed if Condition is True
}
else
{
//Code to be Executed if Condition is False
}
?>
<?php
$a=20;
if($a<=15)
{
echo "The Value is Less Than 20";
}
else
{
echo "The Value is Greater Than 20";
}
?>