Re: Re: $arr = array('Hello', 'world'); $arr();

From: Date: Wed, 08 Jun 2011 13:42:18 +0000
Subject: Re: Re: $arr = array('Hello', 'world'); $arr();
References: 1 2 3 4  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
On Wed, 8 Jun 2011 09:46:26 -0300, Felipe Pena wrote:
It works in the same way: class foo { public function __construct() {
      $this->bar = function () { return 1; };
      // $this->bar(); // error
      $x = $this->bar;
      $x(); // ok
      $this->bar = array($this, 'baz');
      // $this->bar(); // error
      $x = $this->bar;
      $x(); // ok
} public function baz() {
      echo 'baz';
    }
}
OK, my mistake. I thought a property which holds a closure can be called directly. Thanks for clarification. Christian

Thread (9 messages)

« previous php.internals (#53212) next »