02c04-2.php
来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 18 行
PHP
18 行
<?php// Calculating Compound Interest:// a = the initial amount you are calculating from// r = the annual percentage rate// f = the frequency (per year) of compounding// y = the number of years you wish to calculate this for:function calc_compound_interest($a, $r, $f, $y) { return $a * pow((1 + ($r / $f)), ($f * $y));}// Calculate the value of $5000, at 3.25% interest, // compounded daily, for 3 years. Answer: 5512.0332828079echo calc_compound_interest(5000, .0325, 365, 3), '<br />';// Calculate the value of $1000, at 8.5% interest, // compounded monthly, for 6 months. Answer: 1043.2597499629echo calc_compound_interest(1000, .085, 12, .5);?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?