SWITCH CASE
<?php
$var = "YAM";
$hasil = "";
switch($var)
case "HON":
$hasil = "HONDA";
break;
case "YAM":
$hasil = "YAMAHA";
case "SUZ"
$hasil = "SUZUKI";
break;
default:
$hasil = "NULL";
break;
}
echo $hasil;
//memakai function
function myfunc($value)
{
return "<br><br>Pilihan Anda $value";
}
switch($var)
{
case "HON":
$hasil = myfunc("HONDA");
break;
case "YAM":
$hasil = myfunc("YAMAHA");
break;
case "SUZ":
$hasil = myfunc("SUZUKI");
break;
default:
$hasil = myfunc("NULL");
break;
}
echo $hasil;
?>
0 komentar:
Posting Komentar