|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-03-06 12:17 UTC] kalle@php.net
[2010-11-24 10:09 UTC] jani@php.net
-Package: Feature/Change Request
+Package: Scripting Engine problem
[2014-10-12 14:48 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2014-10-12 14:48 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 21:00:02 2025 UTC |
Description: ------------ When returning an anonymous function from a method or function call, the returned closure is not directly executable in a logical fashion. The closure needs to be stored in order to be executed or must be called via the call_user_func family of functions. This is fairly illogical and inconsistent with the idea of closures. Reproduce code: --------------- function test($a) { return function($b) use($a) { echo $a . ':' . $b . '<br/>'; }; } call_user_func(test(1), 2); $x = test(1); $x(2); test(1)(2); Expected result: ---------------- Output should be: 1:2 1:2 1:2 Actual result: -------------- Execution fails. Error: PHP Parse error: syntax error, unexpected '('