[Previous] [Contents] [Next]


Visibility Revisited


Member variables or methods on the base class that are declared public or protected are fully available to any inheriting classes, while properties or methods that are declared as private are not. The one exception to this is if a member function on my base class is protected or publicin that case, I can call it from my inheriting class. The function would then be able to access any private properties or methods:

class ABC
{
  private $abc;

  protected function not_private()
  {
    return $abc;
  }
}

class DEF extends ABC
{
  protected function call_me();
  {
    //
    // when I call this function (which is on my base class)
    // it will have no problems accessing $abc.
    //
    $this->not_private();
  }
}


[Previous] [Contents] [Next]