Created
August 6, 2012 18:25
-
-
Save beberlei/3277334 to your computer and use it in GitHub Desktop.
Proxies with public properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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