Define getter and setter : Getter Setter : Class PHP Source Code


PHP Source Code » Class » Getter Setter »

 

Define getter and setter




<?php

   class Staff {
      private $name;

      // Getter
      public function getName() {
         return $this->name;
      }

      // Setter
      public function setName($name) {
         $this->name = $name;
      }
   }
?>
           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo Class
» Getter Setter