The If-else statement

The if-else statement:
Sometimes when a conditional is not true, you may not want to continue on to the main program code immediately but might wish to do something else instead.this is where the else statement comes in.

The If-Else
The If-Else

With an if…else statement, the first conditional statement is executed if the condition is true.but if it’s false, the second one is executed. One of the two choice must be executed.

   <?php
         $d = date("D");
         
         if ($d == "Fri")
            echo "Have a nice weekend!"; 
         
         else
            echo "Have a nice day!"; 
      ?>



OUTPUT:
Have a nice weekend!

<?php  
$num=12;  
if($num<100){  
echo "$num is less than 100";  
}  
?>  

Output:

12 is less than 100
Translate »