i am working on a simple loan calculator, so simple that it's not even working properly.
function calculatePayment($price, $down, $term)
{
$loan = $price - $down;
$rate = (4/100) / 12;
$month = $term * 12;
$payment = floor(($loan*$rate/1-pow(1+$rate,(-1*$month)))*100)/100;
return $payment;
}
echo calculatePayment(200000,0,30);
this output: 666.36
that would be great if the monthly loan payement is this (not that is the 666 number but low number hahah), my problem is this be higher.
why am i getting the this?
These factors include the total amount you're borrowing from a bank, the interest rate for the loan, and the amount of time you have to pay back your mortgage in full. For your mortgage calc, you'll use the following equation: M = P [ i(1 + i)^n ] / [ (1 + i)^n – 1].
In the Philippines, the monthly amortization should not exceed 40% of the Gross Monthly Income, and Gross Monthly Income can be calculated by simply dividing the monthly amortization by 40%. Monthly amortization – This is the calculated monthly amortization payments in Philippine Peso or PHP.
In theory, calculating your loan payment is simple. You take the total amount you borrowed (known as your principal), and divide it over the number of months over which you agreed to pay back the loan (known as the term).
I just added put (1-pow(1+$rate,(-1*$month))) this because what is happening here is that $loan*$rate will be divided on 1 only then continue
function calculatePayment($price, $down, $term)
{
$loan = $price - $down;
$rate = (4/100) / 12;
$month = $term * 12;
$payment = floor(($loan*$rate/(1-pow(1+$rate,(-1*$month))))*100)/100;
return $payment;
}
echo calculatePayment(200000,0,30);
The answer is 954.83
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With