Class and Object
By: Chrysanthus Date Posted: 4 Dec 2018
<?php
class Calculator
{
public $num1;
public $num2;
public function add()
{
$sum = $this->num1 + $this->num2;
return $sum;
}
}
$myObject = new Calculator();
$myObject->num1 = 2;
$myObject->num2 = 3;
$result = $myObject->add();
echo $result;
?>