3 Aug 2010 13:09
[PHP-DEV] Confusing performance of the magic method __call
Shijiang <shijiang <at> staff.sina.com.cn>
2010-08-03 11:09:46 GMT
2010-08-03 11:09:46 GMT
Hi,
In the following sample code, I expected that the magic method __call only works within the class Test.
But it seems that the access control keyword private lost its efficacy when working together with the magic
method __call.
<?php
class Test{
private function __call($name,$params){
echo $name,"\n";
echo $params[0];
}
public function bar(){
$this->kakaka('afaafaf');
}
}
$foo=new Test;
$foo->bar('sfsfss');
$foo->nothing('works'); // this also works without any errors.
?>
IMHO, since the function __call is a method of a class, it should obey the visibility rules.
Cheers.
RSS Feed