php switch条件选择语句用法示例

前端之家收集整理的这篇文章主要介绍了php switch条件选择语句用法示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP switch条件选择语句使用范例感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!
这段代码判断当前日期是星期几,根据返回值输出Today is Monday的字样,使用switch语句记得每个case后面跟着一个break语句

/**
 * PHP switch条件选择语句使用范例
 *
 * @param 
 * @arrange 512-笔记网: jb51.cc
 **/
$d=date("D");
switch ($d)
{
case "Mon":
  echo "Today is Monday";
  break;
case "Tue":
  echo "Today is Tuesday";
  break;
case "Wed":
  echo "Today is Wednesday";
  break;
case "Thu":
  echo "Today is Thursday";
  break;
case "Fri":
  echo "Today is Friday";
  break;
case "Sat":
  echo "Today is Saturday";
  break;
case "Sun":
  echo "Today is Sunday";
  break;
default:
  echo "Wonder which day is this ?";
}

/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528269.html

猜你在找的PHP相关文章