How To Use Case When In Php

Tanggal : 13 Feb 2023, Category : Tutorial, Create By : admin

The switch statement in PHP can be used as an alternative to multiple if statements. The switch statement tests a variable or expression against multiple cases and executes the code for the matching case. Here's an example of using a switch statement in PHP:

$day_of_week = "Monday";

switch ($day_of_week) {
case "Monday":
echo "Today is Monday";
break;
case "Tuesday":
echo "Today is Tuesday";
break;
case "Wednesday":
echo "Today is Wednesday";
break;
default:
echo "Today is not Monday, Tuesday or Wednesday";
break;
}

In this example, the variable $day_of_week is tested against each case in the switch statement. If the value of $day_of_week is "Monday", the code in the first case will be executed and "Today is Monday" will be outputted. If the value of $day_of_week does not match any of the cases, the code in the default case will be executed.


Keyword:
  • How To Use Case When In Php

Artikel Lain

How To Make A Date Input Type

Date : 14 Feb 2023, Category : HTML, Create By : admin

To create a date input type in HTML, you can use the "date" input type in an HTML form. Here's an example: <form> <label for="birthdate">Birthdate:</label> <input type="date" id="birthdate" name="birthdate"> <input type="submit" .....

Pengertian Dan Kegunaan Php Dalam Membuat Aplikasi Website

Date : 28 Jul 2018, Category : Pemprograman Website, Create By : admin

Selamat datang di website gudangilmuaplikasi.com, dalam membuat sebuah aplikasi bserbasis website, tentunnya kita akan sering menggunakan bahasa pemprograman seperti PHP, HTML, CSS, dan Javascript. kali ini gudangilmuaplikasi.com mencoba akan membahas tentang php, apa .....

How To Care For Thinning And Dandruff Hair Naturally?

Date : 11 Feb 2023, Category : Health, Create By : admin

Hair is a part of the human body that can enhance someone's appearance, so it's no wonder we want strong and healthy hair. However, we often face hair problems such .....