May 2016
Intermediate to advanced
155 pages
2h 15m
English
© Mikael Olsson 2016
Mikael Olsson, PHP 7 Quick Scripting Reference, 10.1007/978-1-4842-1922-5_11
Mikael Olsson1
(1)Hammarland, Finland
Every class member has an accessibility level that determines where the member is visible. There are three of them available in PHP: public, protected, and private.
class MyClass{public $myPublic; // unrestricted accessprotected $myProtected; // enclosing or child classprivate $myPrivate; // enclosing class only}
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'; ...Read now
Unlock full access