Friday, 8 September 2017

How to Use Switch Statements In PHP With Example

How to Use Switch Statements In PHP With Example

Code, Switch Statements , code for Switch Statements, PHP code , code for Switch Statements in PHP
Syntax :

switch(expression){
case value1:
//code to be executed
break;
case value2:
//code to be executed
break;
......
default:
code to be executed if all cases are not matched;
}

PHP Switch Example

Example :

<?php
$num=20;
switch($num){
case 10:
echo("number is equals to 10");
break;
case 20:
echo("number is equal to 20");
break;
case 30:
echo("number is equal to 30");
break;
default:
echo("number is not equal to 10, 20 or 30");
}
?>

Post a Comment

Whatsapp Button works on Mobile Device only

Start typing and press Enter to search