codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?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;
Private
[
?
]
Run code