Skip to content

Instantly share code, notes, and snippets.

@ronindesign
Created November 9, 2015 21:42
Show Gist options
  • Save ronindesign/8a5b72bd8e7ed8a222ce to your computer and use it in GitHub Desktop.
Save ronindesign/8a5b72bd8e7ed8a222ce to your computer and use it in GitHub Desktop.
class Test
{
private $obj;
const MAP = ['testKey' => 'test'];
function __construct() {
$this->obj = new \stdClass();
$this->obj->test = "testObject";
}
public function getConst()
{
$name = 'testKey';
$this->obj->{static::MAP[$name]} = "newObject";
echo $this->obj->{static::MAP[$name]};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment