Posted By

shinokada on 01/20/11


Tagged

php oop getter setter


Versions (?)

getter and setter for private and protected property


 / Published in: PHP
 

To access a protected or private property, you need to create getter and setter methods inside the class file.

  1. // methods defined here
  2. public function getProductType()
  3. {
  4. return $this->_type;
  5. }
  6. public function setProductType($type)
  7. {
  8. $this->_type = $type;
  9. }

Report this snippet  

You need to login to post a comment.