PHP If Else Conditional Statement
What is If Else statement?
Explanation
The conditional statement "else" is used as extension of "if" statement. If the condition fails then it executes another statements under the "else" condition.
Syntax
if (expr)
{Statements}//true
else
{Statements}//false
Based on the result of expressions, the statements are executed.
Example :
<?php
$c = 10;
$d = 20;
if ($c > $d)
{echo "C is bigger than d";}
else
{echo "D is bigger than c";}
?>
Result:
D is bigger than C
In the above example in the if the condition "$c>$d" is true then the message "C is bigger than D" is displayed, else the message "D is bigger than C" is displayed.