PHP Code:
// 5.1.0
class A {
private $priv_var;
private function priv_func() {
echo "func\n";
}
private function __call($m, $a) {
echo "call $m\n";
}
private function __get($p) {
return "get $p\n";
}
}
$x = new A();
echo $x->not_really; // ok
echo $x->priv_var; // ok
$x->not_really(); // ok
$x->priv_func(); // ERROR
__call itself can be private, just like get and friends.
IIRC __get behaviour was changed in 5.1. In 5.0 only "missing" properties were forwarded to __get, as of 5.1 all "unresolvable" requests (undefs + access violations) are forwarded. __call seems still to use 5.0 semantics.
Bookmarks