小编max*_*max的帖子

切换循环无法识别零“0”php

我有这个简单的函数可以将用户的评论数量转换为成员类型。

function checkMemberN($numMessages){
    $n= $numMessages;

    switch ($n) {
        case ($n<50): $type="New"; break;
        case ($n>=50 && $n<250):$type="Frequent";break;
        case ($n>=250 && $n<1000): $type="Master";break;
        default: $type="undefinded";
    }   

    return $type;   
}   

echo checkMemberN(0);
Run Code Online (Sandbox Code Playgroud)

看起来它不能识别零 (0),因为当我输入 1 或更高的数字时,它会检索正确的用户类型。我究竟做错了什么?

php

0
推荐指数
1
解决办法
38
查看次数

标签 统计

php ×1