Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46113 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 35802 invoked from network); 19 Nov 2009 18:40:55 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2009 18:40:55 -0000 Authentication-Results: pb1.pair.com smtp.mail=stas@zend.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=stas@zend.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 212.25.124.185 as permitted sender) X-PHP-List-Original-Sender: stas@zend.com X-Host-Fingerprint: 212.25.124.185 il-mr1.zend.com Received: from [212.25.124.185] ([212.25.124.185:34735] helo=il-mr1.zend.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C3/BD-65535-631950B4 for ; Thu, 19 Nov 2009 13:40:55 -0500 Received: from us-gw1.zend.com (unknown [192.168.16.5]) by il-mr1.zend.com (Postfix) with ESMTP id 357B0504B8; Thu, 19 Nov 2009 20:27:51 +0200 (IST) Received: from [192.168.16.203] ([192.168.16.203]) by us-gw1.zend.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 19 Nov 2009 10:40:48 -0800 Message-ID: <4B059131.9000704@zend.com> Date: Thu, 19 Nov 2009 10:40:49 -0800 Organization: Zend Technologies User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Julien Pauli CC: Jingcheng Zhang , internals@lists.php.net References: <4B045234.1010804@zend.com> <72827a300911191032t249f9e1fi18a8fee476ed7dc0@mail.gmail.com> <4B05905A.2000606@zend.com> In-Reply-To: <4B05905A.2000606@zend.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 19 Nov 2009 18:40:48.0788 (UTC) FILETIME=[D0117540:01CA6947] Subject: Re: [PHP-DEV] The inconsistencies/flaws of PHP5's object model From: stas@zend.com (Stanislav Malyshev) 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 stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com