Skip to content

Instantly share code, notes, and snippets.

@neolao
Created May 20, 2011 15:45
Show Gist options
  • Save neolao/983196 to your computer and use it in GitHub Desktop.
Save neolao/983196 to your computer and use it in GitHub Desktop.
Read only property
public function __get($name)
{
if (method_exists($this, "get_$name")) {
return $this->{"get_$name"}();
} else if (method_exists($this, "set_$name")) {
throw new Exception("Writeonly property $name");
} else {
throw new Exception("Undefined property $name");
}
}
public function get_woot()
{
return 'woot !';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment