[ create a new paste ] login | about

Link: http://codepad.org/75ZWvYI7    [ raw code | output | fork ]

fedecarg - PHP, pasted on Aug 18:
<?php
class Book {
  private $_title;

  function __get($key){
    if (method_exists($this, $method = 'get' . ucfirst($key)))
      return $this->$method();
  }

  function __set($key, $value){
    if (method_exists($this, $method = 'set' . ucfirst($key)))
      return $this->$method($value);
  }

  private function getTitle(){
    return $this->_title;
  }

  private function setTitle($value){
    $this->_title = $value;
  }
}

$book = new Book();
$book->title = 'Code Complete';
echo $book->title;


Output:
1
Code Complete


Create a new paste based on this one


Comments: