How To Use Case When In Php
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
Mengenal Html Textarea
Ketika anda mendaftar di sebuah situs sosial media atau situs pendaftran member anda pastinya di haruskan untuk mengisi formulir atau form input data, dan salah satunya ada yang menggunakan Textarea, apa itu Textarea?. Textarea adalah .....
Belajar Dan Mengenal Perulangan ( Looping ) For Di Php
Selamat datang di website gudangilmuaplikasi.com, dalam belajar pemprograman apapun pasti seorang programmer akan menemukan dan menggunakan perulangan atau looping dalam membuat aplikasinya, entah perulangan untuk menampilkan data dari database maupun perulangan .....
Type Casting In Java
Type casting in Java is the process of converting a variable of one data type into another data type. There are two types of type casting in Java: implicit casting .....