我正在尝试$score
根据其$total_votes
分数更改变量的值。现在的代码(当 I 时echo $score
)每次运行该函数时都会产生一个值 1。这让我相信它$score = $score+1
不能正常工作,代码中是否有我忽略的结构?
public function score($datediff,$total_votes){
$score = 0;
if ($total_votes < 10) { $score = $score+1;}
if ($total_votes > 10 && $total_votes < 100 ) { $score = $score+1;}
if ($total_votes > 100 && $total_votes < 1000 ) { $score = $score+1;}
if ($total_votes > 1000 && $total_votes < 10000 ) { $score = $score+1;}
echo $score.' ';
}