Created
September 26, 2010 20:17
-
-
Save joshtronic/598285 to your computer and use it in GitHub Desktop.
Magic Setter Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function __set($name, $value) | |
{ | |
if (isset($this->$name)) | |
{ | |
trigger_error('Cannot set variable after declaration', E_USER_ERROR); | |
return false; | |
} | |
else | |
{ | |
$this->$name = $value; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment