Skip to content

Instantly share code, notes, and snippets.

@rhowardiv
Created December 3, 2012 20:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rhowardiv/4197652 to your computer and use it in GitHub Desktop.
Save rhowardiv/4197652 to your computer and use it in GitHub Desktop.
PHP magic __get only allows itself on the stack once per property
<?php
class Dumb {
protected $prop;
function __get($p) {
if ($p === 'prop') {
$this->prop = new Dumber($this);
return $this->prop;
}
}
}
class Dumber {
public $prop;
function __construct(Dumb $dumb) {
$this->prop = $dumb->prop;
}
}
$d = new Dumb();
var_dump($d->prop);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment