首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > PHP >

哪位高手能帮小弟我看看这是咋回事

2012-05-13 
谁能帮我看看这是怎么回事?代码如下:?phpfunction amortizationTable($pNum,$periodicPayment,$balance,$

谁能帮我看看这是怎么回事?
代码如下:
<?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);
}else{
return 0;
}
}
$balance=10000.00;
$interestRate=.0575;
$monthlyInterest=$interestRate/12;
$termLength=5;
$paymentsPerYear=12;
$paymentNumber=1;
$totalPayments=$termLength*$paymentsPerYear;
$intCalc=1 + $interestRate/$paymentsPerYear;
$periodicPayment=$balance*pow($intCalc,$totalPayments)*($intCalc-1)/(pow($intCalc,$totalPayments)-1);
$periodicPayment=round($periodicPayment,2);
echo"<table width='50%' align='center' border'1'>";
echo"<tr>
<th>Payment Number </th><th>Balance</th>
<th>Payment</th><th>Principal</th><th>Interest</th>
</tr>";
aomrtizationTable($paymentNumber,$periodicPayment,$balance,$monthlyInterest);
echo"</table>";
?>
为什么显示的结果是下面的:

Fatal error: Call to undefined function aomrtizationTable() in C:\AppServ\www\test.php on line 38
Payment Number Balance Payment Principal Interest 


[解决办法]
aomrtizationTable($paymentNumber,$periodicPayment,$balance,$monthlyInterest);
amo ... 不是 aom
[解决办法]
注意大小写!

PHP code
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);  }else{    return 0;  }} 

热点排行