代码如下:
function amortizationTable($pNum,$periodicPayment,$balance,$monthlyInterest)
{
$paymentInterest=round ($balance*$monthlyInterest,2);
$paymentPrincipal=round ($periodicPayment-$paymentInterest ,2);
$newBalance=round ($balance-$paymentPrincipal,2);
if ($newbalance < $paymentPrincipal){
$newBalance=0;
}
printf("
%d | ",$pNum );
printf("$%S | ",number_format($newBalance,2));
printf("$%S | ",number_format ($periodicPayment,2));
printf("$%S | ",number_format($paymentPrincipal,2));
printf("$%S< /td> |
",number_format($paymentInterest,2));
if($newBalance>0){
$pNum++;
amortizationTable($pNum,$periodicPayment,$newBalance, $monthlyInterest);
}else{
return 0;
}
}
$balance=10000.00;
$interestRate=.0575;
$monthlyInterest=$interestRate/ 12;
$termLength=5;
$paymentsPer Year=12;
$paymentNumber=1;
$totalPayments=$termLength*$paymentsPer Year;
$intCalc=1 + $interestRate/$ paymentPer Year;
$periodicPayment=$balance*pow($intCalc,$totalPayments)*($intCalc-1)/(pow($intCalc,$totalPayments)-1);
$periodicPayment=round($periodicPayment ,2);
echo"
";
echo"
支払い番号< ;/th> | 残高
| 支払い
| 元金
| 利息
|
;";
aomrtizationTable($paymentNumber,$periodicPayment,$balance,$monthlyInterest);
echo"
";
?>
の結果は次のとおりです。
致命的エラー: C:AppServwwwtest.php の 38 行目で未定義関数 aomrtizationTable() を呼び出します
支払い番号残高支払い元本利息
---- --解決策-------------------
aomrtizationTable($paymentNumber,$periodicPayment,$balance,$monthlyInterest);
amo 。 .. 不是 aom
------解决方案---------
注意大小写!<div class="clear"> PHP コード
function amortizationTable($pNum,$periodicPayment,$balance,$monthlyInterest) {
$paymentInterest=round ($balance*$monthlyInterest,2);
$paymentPrincipal=round ($periodicPayment-$paymentInterest ,2);
$newBalance=round ($balance-$paymentPrincipal,2);
if ($newBalance < $paymentPrincipal){
$newBalance=0;
}
printf("<tr>
<td>%d</td>",$pNum);
printf("<td>$%s</td>",number_format($newBalance,2));
printf("<td>$%s</td>",number_format($periodicPayment,2));
printf("<td>$%s</td>",number_format($paymentPrincipal,2));
printf("<td>$%s</td></tr>",number_format($paymentInterest,2));
if($newBalance>0){
$pNum++;
amortizationTable($pNum,$periodicPayment,$newBalance,$monthlyInterest);
}それ以外{
0を返します。
}
</tr>
</div>
ログイン後にコピー