Division by zero error in votes

This question already has an answer here:

  • How to suppress the “Division by zero” error and set the result to null for the whole application? 4 answers

  • This should work for you:

    (It's testing if $total_voting is zero and returns in this case false)

    function percent($liked, $total_voting) {
    
        if($total_voting == 0)
            return false;
    
        $liked = (int)$liked;
        $total_voting = (int)$total_voting;
    
        return ceil(($liked/$total_voting)*100);
    }
    
    链接地址: http://www.djcxy.com/p/69352.html

    上一篇: WordPress分类图像插件显示所有条款

    下一篇: 通过零分错误投票