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.

         $d = date("D");
         if ($d == "Fri")
            echo "Have a nice weekend!"; 
            echo "Have a nice day!"; 

Have a nice weekend!

echo "$num is less than 100";  


12 is less than 100
Translate »