Page 187 - CITS - Computer Software Application -TT
P. 187

COMPUTER SOFTWARE APPLICATION - CITS




           The if...else statement executes some code if a condition is true and another code if that condition is false.
           Syntax
           Example










           Output “Have a good day!” if the current time is less than 20, and “Have a good night!” otherwise:

           PHP - The if...elseif...else Statement


























           The if...elseif...else statement executes different codes for more than two conditions.

           Syntax
           Example


















           Output “Have a good morning!” if the current time is less than 10, and “Have a good day!” if the current time is
           less than 20. Otherwise it will output “Have a good night!”:
           The switch statement is used to perform different actions based on different conditions.
           The PHP switch Statement
           Use the switch statement to select one of many blocks of code to be executed.
           Syntax
           This is how it works:



                                                           174

                             CITS : IT&ITES - Computer  Software Application - Lesson 47 - 62
   182   183   184   185   186   187   188   189   190   191   192