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

Menambah Style Css Dengan Javascript

Date : 10 Sep 2018, Category : JavaScript, Create By : admin

Hai brow, selamat datang kembali di wesbite gudang ilmu aplikasi, kali ini kami akan membahas tentang javascript dan style css, yang kami beri judul menambah style css dengan javascript, dua .....

Pengaturan Firewall Dan Selinux Centos 7

Date : 01 Oct 2018, Category : Server, Create By : admin

FireWall dan Selinux adalah sebuah perangkat atau pengaturan di dalam sebuah operating system linux yang dimana di gunakan sebagai pengaturan sebuah akses perbedaanya adalah jika FireWall di gunakan untuk mengontrol .....

Mengenal Fungsi Implode Php

Date : 04 Jan 2019, Category : Tutorial, Create By : admin

Selamat datang di gudang ilmu aplikasi, setelah kita membahas mengenai explode di artikel sebelumya kini kita akan membahas mengenai implode. Fungsi implode adalah fungsi kebalikanya dari fungsi explode, jika explode .....