Skip to content

Instantly share code, notes, and snippets.

@beberlei
Created August 6, 2012 18:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beberlei/3277334 to your computer and use it in GitHub Desktop.
Save beberlei/3277334 to your computer and use it in GitHub Desktop.
Proxies with public properties
<?php
class Foo
{
public $foo;
}
class FooProxy extends Foo
{
public function __construct()
{
unset($this->foo);
}
public function __set($name, $value)
{
echo "set$name\n";
}
public function __get($name)
{
echo "get$name\n";
}
}
$p = new FooProxy();
$p->foo = "bar";
echo $p->foo;
$p = new FooProxy();
echo $p->foo;
$p->foo = "bar";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment