Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
PHP __get weirdness
// You can do some very odd things with PHP's __get method
class Chain {
private $chain = array();
public static function it() {
return new self;
public function __get($property) {
$this->chain[] = $property;
return $this;
public function __toString() {
return join(" ", $this->chain);
echo Chain::it()->Building->up->a->chain->oh->yeah;
// prints "Building up a chain oh yeah"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.