php switch statements



PHP switch statement

The switch statement is used when we have multiple condition but only one condition true and only that code will be executed.
In other word we can say execute one of multiple blocks of code to be executed.

The switch statement works same as if-elseif-else statement.

PHP switch statement

<?php

switch (a)
{
case statement1:
if a=statement1 then code to be executed;
break;
case statement2:
if a=statement2 then code to be executed;
break;
case statement3:
if a=statement3 then code to be executed;
break;
…….
default:
if “a” is not matches with any statement then code to be executed.
}

?>

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha *