简体   繁体   English

检查变量不小于零

[英]Check variable is not less than zero

I need to Check variable is not less than zero我需要检查变量不小于零

if ( $currentUserLimits >= 0 ) {
        //do something
} elseif($currentUserLimits < $totalPurchaseUnitCount && $currentUserLimits not less then 0) {
        //do something else.
} else {
        //do something else.
}

Clear my question清除我的问题

This is all about offers apply on products and each customer have a purchases limit I have 2 variables and 3 cases.这都是关于适用于产品的优惠,每个客户都有一个购买限制,我有 2 个变量和 3 个案例。

  1. var1 $currentUserLimits which will return the current customer limits. var1 $currentUserLimits将返回当前的客户限制。
  2. var2 $totalPurchaseUnitCount which will return the current purchases. var2 $totalPurchaseUnitCount将返回当前购买。

My 3 cases.我的3个案例。

  1. Case 1: if the $currentUserLimits still > 0 means the customer still have units in offer.情况 1:如果$currentUserLimits still > 0表示客户仍有商品在售。 Ex.前任。 $currentUserLimits = 15 and the $totalPurchaseUnitCount = 10 still the customer has 5 in his $currentUserLimits . $currentUserLimits = 15$totalPurchaseUnitCount = 10仍然客户在他的$currentUserLimits有 5 。
  2. Case 2: if the customer has half of his $totalPurchaseUnitCount in offer and the order half outside the offer.情况 2:如果客户的 $totalPurchaseUnitCount 有一半在报价中,而订单的一半不在报价中。 Ex.前任。 $currentUserLimits = 5 and the $totalPurchaseUnitCount = 10 . $currentUserLimits = 5$totalPurchaseUnitCount = 10
  3. Case 3: if the customer finishes his limits completely so the $currentUserLimits is 0 or less then 0.情况 3:如果客户完全完成了他的限制,则$currentUserLimits为 0 或小于 0。

Sorry making y'all read all this stuff but really the 3 cases confuses me.很抱歉让你们都阅读了所有这些内容,但实际上这 3 个案例让我感到困惑。

how to write not less than 0 not less than 0怎么写

你已经在 ($currentUserLimits >= 0)

Check this out.看一下这个。

if ( $currentUserLimits >= 0 ) {
        //do something
} elseif(($currentUserLimits < $totalPurchaseUnitCount) && !($currentUserLimits < 0)) {
        //do something else.
} else {
        //do something else.
}

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

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