PHP switch case Statement

switch case

PHP switch case statement Use to select one of many blocks of code to be executed.switch-case statement is alternative of the if-elseif-else statement, which does almost the same thing. The switch-case statement tests a variable against a series of values until it finds a match, and then executes the block of code corresponding to that match.

Syntax of switch case statement

 

Example

 

 

 

switch case statement excutes line by line thats why its different form if else statement in php. switch statement executes line by line and once PHP finds a case statement that evaluates to true, it’s not only executes the code corresponding to that case statement, but also executes all the subsequent case statements till the end of the switch block automatically. Read more about Php Knowledge

 

we add a break statement to the end of each case block. break statement tells PHP to break out execution when conditions meet.

I, Dayanand Saini,the founder and chief editor of www.webtechsource.com,have been working as a software engineer from last 4+ years. It's my hobby to learn new things and implement on live environment.

Leave a Reply

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

23 + = 29

%d bloggers like this: