PHP Switch

  • Post
    codeorayo
    Keymaster
    none
    Pernyataan PHP Switch digunakan untuk menjalankan satu pernyataan dari berbagai kondisi. Ini berfungsi seperti pernyataan PHP if-else-if.

    Syntax

    Code:

    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;
    }

    Contoh PHP Switch

    Code:

    Output:

    Code:

    number is equal to 20

    author : javapoint

  • You must be logged in to reply to this topic.