这段代码判断当前日期是星期几,根据返回值输出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) ***/