PHP if else Statements ?


The if else statement is a simple selection/decision statement that is used when we must choose between two alternatives. So it is called two way decision statement.

Syntax:-

if(expression)
{
statement t1
statement t2
statement tn
}
else
{
statement f1
statement f2
statement fn
}

Q.) W.A.P to print the greater number using PHP if-else statement.
 <html>
 <head>
 <title>if else</title>
 </head>
 <body>
 <?php
 $a=6;
 $b=4;
 if($a>$b)
 {
 echo “ A is greater no”;
 }
 else
 {
 echo“B is greater no”;
 }
 ?>
 </body>
 </html>
Output
A is greater no