Description:
The switch statement is used to perform different actions based on different conditions.
Use the switch statement to select one of many blocks of code to be executed.
Code:
<?php
$x=1;
switch($x)
{
case 1;
echo "number 1";
break;
case 2;
echo "number 2";
break;
case 3;
echo "number 3";
break;
default:
echo "no number between 1 and 3";
}
?>
output:
The switch statement is used to perform different actions based on different conditions.
Use the switch statement to select one of many blocks of code to be executed.
Code:
<?php
$x=1;
switch($x)
{
case 1;
echo "number 1";
break;
case 2;
echo "number 2";
break;
case 3;
echo "number 3";
break;
default:
echo "no number between 1 and 3";
}
?>
output:
No comments:
Post a Comment