在課堂作業工作,當我運行這段代碼爲什麼我的功能故障
function paycheck1($hours,$payrate,$othours,$otrate){
if ($hours > $othours){
$total = "<tr><td>".($hours*$payrate)+($hours - $othours)*$otrate."</td></tr>";
return $total;
}
else{
$total = "<tr><td>".$hours * $payrate."</td></tr>";
return $total;
}
}
$pay = 10;
$hours = 50;
$overtime_starts = 40;
$overtime_rate = 15;
echo "<table>";
for ($i=0;$i<$hours;$i++){
echo paycheck1($i, $pay, $overtime_starts, $overtime_rate);
}
echo "</table>";
我得到的輸出喜歡這個
153045607590105120135
0
10
20
30
40.....
爲什麼我收到153045607590105120135
當我運行的代碼。如果我從函數中刪除($hours*$payrate)+
函數 - >如果它工作得很好。爲什麼我得到我使用的是溢出錯誤。
這有幫助嗎? '$ total =「