Skip to content

Instantly share code, notes, and snippets.

@dikiwidia
Created May 5, 2020 18:25
Show Gist options
  • Save dikiwidia/59d070390cea000a08d7d7606f3b39d8 to your computer and use it in GitHub Desktop.
Save dikiwidia/59d070390cea000a08d7d7606f3b39d8 to your computer and use it in GitHub Desktop.
<?php
$angka_pertama = 11;
$angka_kedua = 20;
$kondisi = "penjumlahan";
switch ($kondisi) {
case 'penjumlahan':
if($angka_pertama > 10){
$hasil = "Angka Pertama harus dibawah 10";
} else {
$hasil = $angka_pertama + $angka_kedua;
}
break;
case 'pengurangan':
$hasil = $angka_pertama - $angka_kedua;
break;
case 'perkalian':
$hasil = $angka_pertama * $angka_kedua;
break;
case 'pembagian':
$hasil = $angka_pertama / $angka_kedua;
break;
default:
$hasil = "Anda harus memilih kondisi";
break;
}
echo $hasil;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment