note 117434 added to closure.call

From: Date: Wed, 10 Jun 2015 14:17:09 +0000
Subject: note 117434 added to closure.call
Groups: php.notes 
Request: Send a blank email to php-notes+get-202804@lists.php.net to get a copy of this message
Closure::call() does not exist, at least in PHP 5.5.23 (cli) (built: Mar 21 2015 22:04:59) Instead, to achieve the desired effect: Use the Closure::bindTo() method and invoke the __invoke() magic method from the returned closure. <?php $obj = new stdClass(); $obj->foo = 'baz'; $a = function($arg1, $arg2) { return join(chr(44), [$arg1, $arg2, $this->foo]); }; $b = $a->bindTo($obj); echo $b('foo', 'bar'); ?> ---- Server IP: 72.52.91.14 Probable Submitter: 173.247.1.53 ---- Manual Page -- http://php.net/manual/en/closure.call.php Edit -- https://master.php.net/note/edit/117434 Del: integrated -- https://master.php.net/note/delete/117434/integrated Del: useless -- https://master.php.net/note/delete/117434/useless Del: bad code -- https://master.php.net/note/delete/117434/bad+code Del: spam -- https://master.php.net/note/delete/117434/spam Del: non-english -- https://master.php.net/note/delete/117434/non-english Del: in docs -- https://master.php.net/note/delete/117434/in+docs Del: other reasons-- https://master.php.net/note/delete/117434 Reject -- https://master.php.net/note/reject/117434 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#202804) next »