Posts

Showing posts with the label php switch statement

PHP Switch Statement

Image
Switch Statement in PHP PHP Switch Statement The switch statement is used to execute various actions based on different conditions . Key points about switch case to be noticed: The switch statement can have one default only. Over one default may result in a fatal error. Each case may have a statement of the break, which is used to terminate the statement sequence. PHP allows you to use any number, character, string and switch expression function. you can use semicolon(;), colon(:). it will not generate any error syntax of a switch statement in PHP switch (n) {     case label1:         code to be executed if n=label1;         break;     case label2:         code to be executed if n=label2;         break;     case label3:         code to be executed if n=label3;         break;     ...   ...