O'Reilly logo

PHP Quick Scripting Reference by Mikael Olsson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 11

image

Access Levels

Every class member has an accessibility level that determines where the member will be visible. There are three of them available in PHP: public, protected and private.

class MyClass{  public    $myPublic;    // unrestricted access  protected $myProtected; // enclosing or child class  private   $myPrivate;   // enclosing class only}

Private access

All members regardless of access level are accessible in the class in which they are declared, the enclosing class. This is the only place where a private member can be accessed.

class MyClass{  public    $myPublic    = 'public';  protected $myProtected = 'protected';  private   ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required