Hi!

call_user_func(array($o,'f')); leads to fatal error, I think the same

Of course, since you again asked to call method 'f'. Try:
call_user_func($o->f);

Ah, didn't notice you already wrote that. Anyway, the difference is that methods and properties in PHP, unlike Javascript, live in different spaces. In Javascript, it is necessary to join spaces since it is the only way to define methods - there are no class definitions there. However, PHP works in different way. So, you can do one of two things:
1. call method (real one, defined in a class) by name
2. call variable that contains "callable" - which can be function name, pair of "class, method" or "object, method", or invokable object - such as Closure. That is done by call_user_func or __invoke.
--
Stanislav Malyshev, Zend Software Architect
s...@zend.com   http://www.zend.com/
(408)253-8829   MSN: s...@zend.com

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to