计算PHP中的百分比给出错误的结果

Here is the problem

I have 200 votes and 53 of them must be calculated as the porcent so I run this example to test the math first

$total="200";
$votes="53";
$calculate=($total / 100) * $votes;
echo "The porcent of votes is ".$calculate." ";

The result must be something like 26% but I get

Result 53% ...

What can be wrong ?

Here:

<?php

$total="200";
$votes="53";
$calculate=($votes * 100) / $total;
echo "The porcent of votes is ".$calculate."%";

Your calculate formula is wrong. If you want to calculate the percent of any number, you need the given or scored number and the total number. In your case, given is or score is 53 and total it 200. So you divide given or score by total and the multiply the results by 100 to get the percent. See below.

$total="200";
$votes="53";
$calculate=($votes / $total) * 100;
echo "The porcent of votes is ".$calculate." ";

Let me know if this helps. Stay warm!