Ejemplo n.º 1
0
    }
    function setInput2($number)
    {
        $this->input2 = (int) $number;
    }
    function calculate()
    {
        $this->output = $this->input1 * $this->input2;
    }
    function getResult()
    {
        return $this->output;
    }
}
$ex = new Calc();
$ex->setInput1(5);
$ex->setInput2(20);
$ex->calculate();
$ex->getResult();
// if I tries to get the result but just calling the variable $ex->$output
// it throws an error since it is a private variable
//
// A Private variable is one that is only alailable to the class itself...
// however the protected variable is available to the class and all of
// the children classes
// this is a brief example of how the extended class can use the input2
// variable however I still need a function in this new class to return it
// outside the class.
class Test extends Calc
{
    function getinput2()