Private and protected variables : protected « Class « PHP






Private and protected variables

 
<?php

class Staff
{
    private $name;
    private $title;
    protected $wage;
    protected function clockIn() {
        echo "Member $this->name clocked in at ".date("h:i:s");
    }
    protected function clockOut() {
        echo "Member $this->name clocked out at ".date("h:i:s");
    }
}

?>
  
  








Related examples in the same category

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