Breaking

LightBlog

Saturday 4 July 2015

Switch Statement in PHP Tutorial


Switch Statement: Switch statement is used to perform one of several different actions based on one of several different conditions. If you want to select one of many blocks of code to be executed, use the Switch statement. Syntax

switch(expression )
{
case 1:
statement 1;
break;
case 2:
statement 2;
break;
default:
wrong statement;
}
                               

Program
<?php 
switch($page)                                                                                                                                                 
case "Home" : 
echo "You are select the Home";
break;
case "About":
echo "You are select the About us";
break;
case "Gallery" : 
echo "You are select the Gallery";
break;
case "Contact us":
echo "You are select the Contact  us";
break;
default:
echo "your choice is worng";
?>
                                                                                                                                                                                                
                                               
Adbox