Diogo Neves schreef:
thanks,

well, the 'new' woks the same with ou without '()' after class, I think...

you think? I gave you code that shows exactly that.
but you wrote the following:

        new $user = new user();

which is not correct, the first new in that line is a syntax error.
that means you didn't cut and paste the exact code you were using,
which is bad practice.

and I now how it works, i only don't understand why... if the method
is not available outside of class it should go to __call function like
if it doesn't exist...

this is not how it works. 'method is not available' does not mean 'method
does not exist', __call is executed when a method does not exist.

it doesn't make any sense to anyone else?


it makes sense that you think it should work the way you describe,
but it doesn't. it's not a bug it's by design.

also your example is rather silly. you make a method private
then you want to expose the very same method publically via __call(),
quite simply the method should be public in that example.


On Sat, Aug 30, 2008 at 2:38 PM, Jochem Maas <[EMAIL PROTECTED]> wrote:
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



---- ----
Thanks by your attention,

Diogo Neves
Developer @ Sapo.pt by PrimeIT.pt



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to