After some time with JS and Python, this week I have decided to continue with PHP. So, let’s see how you can make a class with a function in PHP.
My class would be called Investment, with 3 public variables – interest, amount and result. The function would take two variables and produce value to the third.
$this->result = $this->amount * $this->interest+ $this->amount;
$investment = new Investment;
$investment->interest = 0.1;
$investment->amount = 250;
echo "Finally I calculated that from <br>".$investment->amount."
if we have ".$investment->interest." we will get ".$investment->result.". <hr>";
And this happens if you call it in a browser:
Yup, I really have Apache on port 81 :).
The code is available in GitHub here.