php使用switch分支语句的简单示例

前端之家收集整理的这篇文章主要介绍了php使用switch分支语句的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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)   ***/
原文链接:https://www.f2er.com/php/528503.html

猜你在找的PHP相关文章