我在弄清楚为什么以下代码不起作用时遇到问题。它返回正确的数字,但是当它达到-1时,页面应该停止。
日期字段是mysql数据库中的日期。
$date = new DateTime(date("Y-m-d", strtotime($pay_posted1)));
$date->modify('+'.$time_frame1.' months');
$NEW_DATE = $date->format('Y-m-d');
$firstp = new DateTime(date("Y-m-d")); //CURRENT DATE
$secondp = new DateTime(date("Y-m-d", strtotime($NEW_DATE)));
$diffp = $firstp->diff($secondp);
$DIFFp = $diffp->format('%R%a');
$DIFF_p = $diffp->format('%a');
if ($DIFFp == +0) {
$PAYMENT_ERROR = "<center><h2><b><font color='#FF0000'>PAYMENT DUE
TODAY <a href=\"javascript:void(window.open('payment_history.php',
'',
'width=500,height=600,top=10,left=40,scrollbars=yes'))\">(View)
</a>
</font></b></h2></center>";
} elseif($DIFFp <= +10) {
$PAYMENT_ERROR = "<h2><b><font color='#FF0000'>PAYMENT DUE IN
$DIFFp DAY(S)</b></font></h2>";
} elseif ($DIFFp <= -1) {
$PAYMENT_ERROR = "<br><br><br><br><h1><b><font
color='#ff0000'>PAYMENT IS PAST DUE!! <br>
PLEASE FOLLOW THIS <a
href='http://wawoffice.net/contact.php'>LINK</a></font></h1>";
exit();
} else {
$PAYMENT_ERROR = "";
}
谢谢
答案 0 :(得分:1)
-1匹配条件elseif($DIFFp <= +10)
,因此将永远不会到达最后一个elseif
,您需要颠倒elseif
子句的顺序。
答案 1 :(得分:0)
谢谢。就是这样,不知道我怎么想念它。