我很难理解为什么下面的代码不起作用。它返回正确的数字,但当它达到-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 = "";
}
谢谢
2条答案
按热度按时间z3yyvxxp1#
-1符合条件
elseif($DIFFp <= +10)
所以最后一个elseif
永远都达不到,你需要颠倒顺序elseif
条款。wh6knrhe2#
谢谢你gramamj42。就是这样,我不知道我怎么会错过。