Class using access control : protected « Class « PHP






Class using access control

 
class Person {
    public $name;     
    protected $age;   
    private $salary;  

    public function __construct() {
    }

    protected function set_age() {
    }

    private function set_salary() {
    }
}
  
  








Related examples in the same category

1.protected member variable
2.Class members' visibility
3.Private and protected variables
4.Properties and methods marked as protected are accessible only through the object that owns them