嘿,人们快速提问,我正在尝试为客户更新网站,他们希望在某些日期发布某些号码。我写的代码是:
<?php
if (is_page( XXXX )) && ((date('m') == 9)) && ((date('d') == 2)){
echo 'To speak to an attorney about this practice area, please call XXX-XXX-XXXX';
} elseif ((date('m') == 10)) && ((date('d') == 16)) {
echo 'To speak to an attorney about this practice area, please call XXX-XXX-XXXX';
}
?>
有什么我想念的吗?代码无效。请告知...并提前谢谢
答案 0 :(得分:0)
您需要在if语句的括号中包含所有条件:
<?php
if (is_page( 'XXXX' ) && (date('m') == 9) && (date('d') == 2)){
echo 'To speak to an attorney about this practice area, please call XXX-XXX-XXXX';
}
elseif ((date('m') == 10) && ((date('d') == 16))) {
echo 'To speak to an attorney about this practice area, please call XXX-XXX-XXXX';
}
?>
答案 1 :(得分:0)
这应该有效:
<?php
if (is_page( XXXX ) && date('m') == 9 && date('d') == 2){
echo 'To speak to an attorney about this practice area, please call XXX-XXX-XXXX';
} elseif (date('m') == 10 && date('d') == 16) {
echo 'To speak to an attorney about this practice area, please call XXX-XXX-XXXX';
}
?>
您使用了太多括号。