Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

PHP Switch Statement

PHP (Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.

PHP is a server-side scripting language designed for web development but also used as a general-purpose programming language.Originally created by Rasmus Lerdorf in 1994.

PHP code may be embedded into HTML code, or it can be used in combination with various web templates. PHP code may also be executed with a command-line interface (CLI) and can be used to implement standalone graphical applications.

Switch  Statement:

The switch statement is to select one of many blocks of code to be executed.

Syntax

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;

    …

 default:

     code to be executed if n is different from all labels;

}

Program:

Output:

Categories PHP