如何在PHP中计算NPER

时间:2016-09-09 09:29:32

标签: php math

我无法弄清楚如何在php中计算NPER。

我在google中找不到任何文章。

我的数学非常弱,因为我正在寻求帮助。

这就是我到目前为止所做的:(

public function Nper($interest, $payment, $loan){
       $nperC = Log10($payment/($payment+$loan+$interest))/Log10(1+$interest);
       return $nperC;
}
if(isset($_POST['NperSubmit'])){
        $calc = new CalculatorModel();
        $months = $calc->Nper($_POST['interest'], $_POST['payment'], $_POST['loan']);
        echo round($months,2);
}

工作代码(来自Tijo John回答)

public function Nper($interest, $payment, $loan){
        $interest = $interest / 1200;
        $nperC = Log10 ($payment/ ($payment- $loan * $interest)) / Log10(1 + $interest);

        return $nperC;
    }
    $calc = new CalculatorModel();
    $months = $calc->Nper($_POST['interest'], $_POST['payment'], $_POST['loan']);
    echo round($months,2);

谢谢:))

1 个答案:

答案 0 :(得分:3)

我认为您应该更改公式如下

Log10($ payment /($ payment- $ loan * $ interest))/ Log10(1 + $ interest)