Mega Code Archive

 
Categories / Php / Class
 

Properties and methods marked as protected are accessible only through the object that owns them

<?     class Dog {             public $Name;             private function getName( ) {                     return $this->Name;             }     }     class Poodle extends Dog {             public function bark( ) {                     print "'Woof', says " . $this->getName( );             }     }     $poppy = new Poodle;     $poppy->Name = "Poppy";     $poppy->bark( ); ?>