Future Value Calculator
/* Here's a good place to use the null coalescing operator
to test the $investment, $interest_rate, $years
to see if they have any values, and set to null otherwise.
This is because this page will be loaded the very first time
when these variables have never been used before (no values yet),
as well as when there have been errors detected and the page
is reloaded. No way of knowing unless you test the variables.
What kind of test? If you attempt to assign $investment to $investment (yup, you read that correctly--assign it to itself!), and if it's not set, assign it a NULL. Then, it won't be considered "undefined" when you attempt to print it later in the form. But, interestingly, if the user doesn't enter anything for it, and you attempt to post $investment to the next page (display_results.php), it will be considered an empty string and will pass that test next time. Whew!
*/
?>
There are 3 Steps involved in it
See step-by-step solutions with expert insights and AI powered tools for academic success
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started