Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53211 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 69557 invoked from network); 8 Jun 2011 13:40:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2011 13:40:03 -0000 Authentication-Results: pb1.pair.com smtp.mail=j.boggiano@seld.be; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=j.boggiano@seld.be; sender-id=pass Received-SPF: pass (pb1.pair.com: domain seld.be designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: j.boggiano@seld.be X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:41902] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 10/E2-48516-2BB7FED4 for ; Wed, 08 Jun 2011 09:40:03 -0400 Received: by bwz18 with SMTP id 18so478521bwz.29 for ; Wed, 08 Jun 2011 06:39:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.205.35.1 with SMTP id su1mr867649bkb.129.1307540399216; Wed, 08 Jun 2011 06:39:59 -0700 (PDT) Received: by 10.204.119.6 with HTTP; Wed, 8 Jun 2011 06:39:59 -0700 (PDT) In-Reply-To: References: <67f900ce904612afdba7650ccbed6ed4@mohiva.com> <4ec16f049f8a5946bca7e81ecec50b45@mohiva.com> Date: Wed, 8 Jun 2011 15:39:59 +0200 Message-ID: To: Felipe Pena Cc: Christian Kaps , internals@lists.php.net Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Re: $arr = array('Hello', 'world'); $arr(); From: j.boggiano@seld.be (Jordi Boggiano) On Wed, Jun 8, 2011 at 2:46 PM, Felipe Pena wrote: > class foo { > =A0 public function __construct() { > =A0 =A0 =A0$this->bar =3D function () { return 1; }; > =A0 =A0 =A0// $this->bar(); // error > =A0 =A0 =A0$x =3D $this->bar; > =A0 =A0 =A0$x(); // ok > > =A0 =A0 =A0$this->bar =3D array($this, 'baz'); > =A0 =A0 =A0// $this->bar(); // error > =A0 =A0 =A0$x =3D $this->bar; > =A0 =A0 =A0$x(); // ok > =A0 } > =A0 public function baz() { > =A0 =A0 =A0echo 'baz'; > =A0 =A0} > } What he meant was passing an existing method as a callback if you don't invoke it, i.e. passing "$this->bar" instead of array($this, "bar"). I don't know how hard it'd be to achieve, but it sounds pretty awesome to me. Cheers --=20 Jordi Boggiano @seldaek :: http://seld.be/