Re: Function __call

From: Date: Sat, 30 Aug 2008 13:38:00 +0000
Subject: Re: Function __call
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-279082@lists.php.net to get a copy of this message
Diogo Neves schreef:
hi all, I'm sending this email only to ask if someone know if the works of __call in private methods is bug or feature. ex. class user { public function __call ( $name, $arguments ) { do something return call_user_func( array( $this, $name ), $arguments );
the fatal error occurs because the method exists, but it's private ... __call() is only called if the method does not exist at all: class user { public function __call($m, $a) { if (is_callable(array($this, "_".$m))) return $this->{"_".$m}( $a ); } private function _xpto($a) { var_dump($a); } } $u = new user; $u->xpto(1, 2, 3);
} private function xpto ( $arguments ) { do something } } new $user = new user();
the first 'new' is incorrect me thinks.
$user->xpto(); error: Fatal error: Call to private method user::xpto() from context '' in xpto.php on line 11 PS: what a fucking I was thinking? well, it don't have this public method, then it sholdn't know it exists, then go to __call() i really don't know if it make any sense to someone else, but it still make sense to me any thoughts? ---- ---- Thanks by your attention, Diogo Neves Developer @ Sapo.pt by PrimeIT.pt


« previous php.general (#279082) next »