Re: The inconsistencies/flaws of PHP5's object model
| From: | Stanislav Malyshev | Date: | Thu, 19 Nov 2009 18:40:49 +0000 |
| Subject: | Re: The inconsistencies/flaws of PHP5's object model | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46113@lists.php.net to get a copy of this message | ||
Hi!
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 stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.comcall_user_func(array($o,'f')); leads to fatal error, I think the sameOf course, since you again asked to call method 'f'. Try: call_user_func($o->f);