This is a simple calculator written in PHP using Object Oriented Programming (OOP) concepts
It takes two numbers as properties and returns the below calculations using methods built into the Class:
- Multiplication
- Division
- Addition
- Subtraction
- Exponent
The two set of numbers hardcoded into this program are:
$calc1 -> number1 = 6;
$calc1 -> number2 = 3;
and
$calc2 -> number1 = 4;
$calc2 -> number2 = 2;
The output is as follows:
6 x 3 = 18
6 / 3 = 2
6 + 3 = 9
6 - 3 = 3
6 ** 3 = 216
4 x 2 = 8
4 / 2 = 2
4 + 2 = 6
4 - 2 = 2
4 ** 2 = 16
Second file: oop-calculator2.php:
- Added a setter and getter and changed the first set of numbers to show how these can be used