我一直在嘗試將PHP中的PMT函數作爲貸款計算器來使用。PHP中的PMT函數
PHP代碼不起作用,我不太清楚爲什麼,請注意我是一個完整的初學者。
PHP(Get.php):
<?php
$loan = $_POST["loanamount"];
$interest = $_POST["interest"];
$months = $_POST["months"];
function pmt($interest, $months, $loan) {
$months = $months;
$interest = $interest/1200;
$amount = $interest * -$loan * pow((1 + $interest), $months)/(1 - pow((1 + $interest), $months));
return number_format($amount, 2);
}
echo "Your payment will be £" . round($amount,2) . " a month, for " . $months . " months";
?>
HTML:
<form action="get.php" method="post">
Loan Amount: <input type="text" min="1" name="loanamount"><br />
Intrest: <input type="text" min="1" name="interest"><br />
Months: <input type="text" min="1" name="months"><br />
<input type="submit" value="Submit">
Monthly repayment:
</form>
請多關照。
因爲你永遠不會真的*調用* pmt()函數。 – deceze 2014-10-27 11:12:14