繁体   English   中英

if语句中的负数

[英]Negative numbers in if statement

负数说明。

我有这个:

$start_ts1 = strtotime(date("Y-m-d H:i:s"));
$end_ts1 = strtotime($app_date);
$diff1 = $end_ts1 - $start_ts1;
$DIFF1 = round($diff1 / 86400);

这确实返回一个负数(工作正常),但是我对执行if语句很不满意。

我有这个:

if($DIFF1 <= 0) {
    //do when it is negative
} else {
    //else if false
}

通常小于或等于也是负数。 这个对吗?

0不视为负数。 在if中使用“ <”代替。

if($DIFF1 < 0) {
//case for negative difference
} else {
//case for 0 or positive difference
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM