answersLogoWhite

0


Best Answer

The formula for compound interest is Final amount = Base amount * (1+(rate of interest/times compounded per year))^(number of times compounded per year * how many years pass)

To put this into PHP, it would go something like this:

function calcInt($rate, $numYear, $yearsElapsed, $base)
{
$finalAmount = $base*((1+($rate/$numYear))^($numYear*$yearsElapsed));
return $finalAmount;
}

To call this function and print the output, put:

echo $finalAmount(.05, 2, 4, 5000);

That would output the final amount if the interest rate is 5%, it's compounded twice per year, 4 years elapse, and the initial amount was $5000.

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Php code for calculating compound interest?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How do you create an area of a webpage to display PHP results?

PHP code blocks start with <?php and end with ?>.


Why you do not see any PHP code when you view the source code of a PHP page in the browser?

PHP is server-side, the browser itself does not interpret it. Rather, the browser sends a query to the server, and the PHP scripting generates custom HTML document. It is this HTML that you are seeing the source code of.


How do you embed PHP code in C code?

PHP and C are two different programming languages that cannot directly interact with eachother. You can have a program made with C call a PHP script, using its output (an indirect interaction), but there's no way to "embed" PHP into C code.


How is PHP code designated in a webpage?

PHP code is never executed by the web browser, and the source code of a PHP file will normally not be sent to the browser at all. In this sense, there is no designation of PHP code on the client's side-- it all appears to be HTML, text, XML, or whatever other type of output you choose to produce. On the server side, PHP scripts are inside of files ending in ".php". Script inside of these PHP files start with . Anything outside of these tags will be sent to the browser as static ("unchanging") output. The code inside the PHP tags start from the top, and are executed sequentially from top to bottom, unless flow control is used to modify the control of the scripts (such as functions, while loops, switch and if constructs, etc).


What is the php code to close the existing window using button?

It is not a PHP code but a Javascript code. w3schools.com has all the answers you need about Javascript. It will teach you how to use the code and implement it into your website. If you're creating your own websites I suggest you actually learn the code. It will come in handy later on.

Related questions

What is syntax in php?

We can use php tags in different ways. <?php //php code to be written here ?> OR <? //php code ?> This tag will not work when we using editors such as macromedia dreamweaver. OR < script language="php"> //php code </script>


How do you change the language code in a PHP page?

I have little idea of your question however <?php #code in here ?> is the starter for PHP, and then anything outside is HTML.


How do you create an area of a webpage to display PHP results?

PHP code blocks start with <?php and end with ?>.


What file extension is used to save a php file after code has been written into it?

The file extension for PHP is .php


Why you do not see any PHP code when you view the source code of a PHP page in the browser?

PHP is server-side, the browser itself does not interpret it. Rather, the browser sends a query to the server, and the PHP scripting generates custom HTML document. It is this HTML that you are seeing the source code of.


How do you embed PHP code in C code?

PHP and C are two different programming languages that cannot directly interact with eachother. You can have a program made with C call a PHP script, using its output (an indirect interaction), but there's no way to "embed" PHP into C code.


You want to use the information entered in a form of a HTML file in the PHP file to calculate simple interest tell the code?

Due to technical limitations I cannot post the code here. You can find the code at http://www.technowiki.info/simple_interest.txt .


What are semantics in PHP?

In PHP, semantics refer to the meaning of code or how statements are interpreted by the PHP engine. It involves understanding how code functions and interacts with other elements in a PHP script. Proper semantics ensure that the code behaves as expected and follows the established rules of the PHP language.


Is it able to send recurring eMail with PHP code such as sending an eMail every month automatically with PHP code?

By making use of Linux's cron jobs, you could schedule a PHP job to be run monthly using this line of code at the bottom of the file opened by running crontab -e:0 0 1 * * /usr/local/bin/php /path/to/php/file.phpIn that PHP file you could have your code to send an email like so:


What is meaning of PHP is an open source software?

It means that the source code of PHP (not PHP code, but the C/C++ code used to build the PHP binary) is published and available to anyone. It also means that anyone can contribute fixes and improvements to the source code.Read more here: open-source


What is a PHP parser?

PHP is a programming language, and parser specifically is part that reads human-readable representation of code to generate parse tree and later opcode representation of code that can be interpreted by php interpreter.


Why did the definition of php change?

PHP stands for hypertext preprocessor. It is the code embedded within the HTML of a web page. A php change is when this language is changed.