案例:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/b269ee691e9ff811cf71ee19bbaeddf0.png)
个人所得税税率表:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d596ff207f06f8b8b03547269e5feda8.png)
以下为当前最新个税计算方法,
function gs()
{
$month = 12;
$salary = 30000;
$other = 6500;
$minus = 0;
$tax = 0;
$nowTax = 0;
$allSalary = 0;
for ($i = 1; $i <= $month; $i++) {
$allSalary = ($salary * $i - 5000 * $i - $other * $i);
if ($allSalary <= 36000) {
$minus = 0;
$rate = 0.03;
} elseif ($allSalary < 144000) {
$minus = 2520;
$rate = 0.1;
} elseif ($allSalary < 300000) {
$minus = 16920;
$rate = 0.2;
} elseif ($allSalary < 420000) {
$minus = 31920;
$rate = 0.25;
} elseif ($allSalary < 660000) {
$minus = 52920;
$rate = 0.3;
} elseif ($allSalary < 960000) {
$minus = 85920;
$rate = 0.35;
} else {
$minus = 181920;
$rate = 0.45;
}
$nowTax = ($salary * $i - 5000 * $i - $other * $i) * $rate - $minus - $tax;
echo "当月应纳税所得额:$allSalary ,".$i. "月税额:($salary * $i - 5000 * $i - $other * $i) * $rate - $minus - $tax = ".$nowTax.PHP_EOL;
$tax += $nowTax;
}
echo "总税额:$tax".PHP_EOL;
}
结果:
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/8b1b037cdd2c4a5592edd4ab76f97454.png)