Skip to content

Instantly share code, notes, and snippets.

@honbin
Created December 6, 2012 04:59
Show Gist options
  • Save honbin/4221875 to your computer and use it in GitHub Desktop.
Save honbin/4221875 to your computer and use it in GitHub Desktop.
<?php
class Test
{
private $hoge = "hoge";
public function __get($property)
{
if(property_exists($this, $property)) {
return $this->$property;
}
}
public function __set($property, $value)
{
if(property_exists($this, $property)) {
$this->$property = $value;
}
return $this;
}
}
$obj = new Test();
echo $obj->hoge; #=>hoge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment