|
对php中使用switch分支语句范例感兴趣的小伙伴,下面一起跟随脚本之家 jb51.cc的小编两巴掌来看看吧!
/**
* php中使用switch分支语句范例
*
* @param
* @arrange 512-笔记网: www.www.jb51.cc
**/
<?php
//Initializing variables
$a = 10;
$b = 5;
echo("1. Addition <br>");
echo("2. Subtraction <br>");
echo("3. Multiplication <br>");
echo("4. Division <br>");
$ch=3;
switch ($ch)
{
case 1:
$d=$a+$b;
echo("The sum of the two numbers is $d");
break;
case 2:
$d=$a-$b;
echo("The difference of the two numbers is $d");
break;
case 3:
$d=$a*$b;
echo("The product of the two numbers is $d");
break;
case 4:
$d=$a/$b;
echo("The quotient of the two numbers is $d");
break;
default:
echo("Incorrect Option");
break;
}
/*** 来自脚本之家 jb51.cc(jb51.cc) ***/ (编辑:安卓应用网)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|