class member variable access: private : private « Class « PHP






class member variable access: private

<?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.Access private properties with for each loop
2.Changing the member $a to protected or private
3.Using private and public in Classes
4.If the variable was defined as private static, it would not be possible to access it directly
5.Private and inheritance
6.Private properties are accessible only inside the methods of the class that defined them
7.Protect the class from being misused by accessing the members directly