如果它们是真正的PHP,如何处理所有情况
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如果它们是真正的PHP,如何处理所有情况,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1207字,纯文字阅读大概需要2分钟。
内容图文
![如果它们是真正的PHP,如何处理所有情况](/upload/InfoBanner/zyjiaocheng/808/74028a6b9a7046cc82b2329e6ba16d7e.jpg)
我想知道是否有办法完成所有三种情况,如果它们都是真的,但使用break,因为例如,如果第一种情况为真,则第二种情况为假,第三种情况也为假,而且我没有使用休息,无论如何它都会进入低谷.2014年10月6日改变了strtotime,你会看到我的意思
$date = strtotime("1 October 2014");
switch($date) {
case (date('l', $date) == 'Monday'): //case 1: If the current day is Monday
echo "weekly<br>";
break;
case (date('d', $date) == '01'): //case 2: If the current day of the month is 1
echo "monthly<br>";
break;
case ( ((date('n') % 3) == '1') && (date('d') == '01') ): //case 3: If a quart of the year has just passed,and we are in the first day of a new quart
echo 'quarterly<br>';
break;
}
有什么建议吗?如果切换不可能,如果要执行代码行3次,每个情况一个,我应该怎么做.
解决方法:
尝试
$date = strtotime("1 October 2014");
if (date('l', $date) == 'Monday'){ //case 1: If the current day is Monday
echo "weekly<br>";
}
if (date('d', $date) == '01'){ //case 2: If the current day of the month is 1
echo "monthly<br>";
}
if ( ((date('n', $date) % 3) == '1') && (date('d', $date) == '01') ){ //case 3: If a quart of the year has just passed,and we are in the first day of a new quart
echo 'quarterly<br>';
}
内容总结
以上是互联网集市为您收集整理的如果它们是真正的PHP,如何处理所有情况全部内容,希望文章能够帮你解决如果它们是真正的PHP,如何处理所有情况所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。
来源:【匿名】