Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Person
- {
- private $firstname;
- private $lastname;
- public function __construct($pFirstname, $pLastname)
- {
- $this->firstname = $pFirstname;
- $this->lastname = $pLastname;
- }
- public function __set($name, $value)
- {
- if(isset($this->$name))
- {
- $this->$name = $value;
- return true;
- }
- $error = "Error: __set property: " . $name . " not supported by class: " . __CLASS__ ;
- throw new Exception($error);
- return false;
- }
- public function __get($name)
- {
- if(isset($this->$name))
- return $this->$name;
- $error = "Error: __get property: " . $name . " not supported by class: " . __CLASS__ . ".";
- throw new Exception($error);
- return false;
- }
- public function __toString()
- {
- return $this->firstname . " " . $this->lastname;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement