|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-03-02 21:27 UTC] nikic@php.net
-Summary: unable to directly execute a closure
+Summary: Add ability to directly execute a closure
-Type: Bug
+Type: Feature/Change Request
-Package: *Programming Data Structures
+Package: Scripting Engine problem
[2014-10-12 15:06 UTC] nikic@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: nikic
[2014-10-12 15:06 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 23:00:01 2025 UTC |
Description: ------------ You cannot directly execute a closure. Prevents code such as <?php $condition ? function () { // path a }() : function () { // path b }(); Which can be useful in various cases. Test script: --------------- <?php function () { echo 'test'; }(); function () { echo 'tickle'; }->__invoke(); Expected result: ---------------- testtickle Actual result: -------------- PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in php shell code on line 1 PHP Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in php shell code on line 1