Php Switch statement is very useful, it works like if/else statement & reduce the complication of numerous conditions in the script.
Syntax :
switch (expression)
{
case 1
code .. //execute code if expression = 1
break;
case 2
code ... //execute code if expression = 2
break;
default:
code...//execute code if expression not matched
}
Example :<?php
$value = 6;
switch ($value)
{
case 1:
echo "Value 1";
break;
case 2:
echo "Value 2";
break;
case 3:
echo "Value 3";
break;
default:
echo "Value is " . $value . " not matched!";
}
?>
1 comment:
Hi,
I am looking to build links on my website, i could add your site to PC Hack, PR3 and to Free PHP Code
In return i would ask that you add my link
Please email me at hackspc@gmail.com if you would like to go ahead.
Many thanks
Ivan
Post a Comment