|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-08-17 22:17 UTC] giorgio dot liscio at email dot it
Description:
------------
hi, would be nice having this syntax for closures
$this->addResult
(
(
function ($param) use ($x) { return $x*$param; }
)($result)
);
a closure defined and executed in the same instruction, as JavaScript allows
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 07:00:02 2025 UTC |
any alternative syntax can be good if the result is the same, defining end invoking on the same instruction without using any var now: $f = function($x) use($y){return $x * $y;}; $f(22); request: (function($x) use($y) {return $x * $y;})(22); or function($x) use($y) {return $x * $y;}(22); or function($x) use($y) invoke(22) {return $x * $y;}; etcI like the: function($x) use($y) {return $x * $y;}(22); approach, its consistent with that of other languages, like JavaScript