php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #62386 Closures require arguments in function header
Submitted: 2012-06-22 00:35 UTC Modified: 2012-06-22 04:19 UTC
From: Daniel dot L dot Nill at gmail dot com Assigned:
Status: Closed Package: Unknown/Other Function
PHP Version: 5.3Git-2012-06-21 (Git) OS: linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
17 - 16 = ?
Subscribe to this entry?

 
 [2012-06-22 00:35 UTC] Daniel dot L dot Nill at gmail dot com
Description:
------------
There seems to be no reason for this throwing an error, but if I try to 
instantiate an anonymous function that does not have any arguments then I get an 
'Parse error'.  This breaks a lot of closure functionality that could exist.

Test script:
---------------
$anonymous_function = function(){
    echo "hello world<br/>";
};

$anonymous_function();
$anonymous_function;

Expected result:
----------------
hello world
hello world

Actual result:
--------------
Parse error: syntax error, unexpected T_FUNCTION in /index.php(192) : eval()'d 
code on line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-22 02:16 UTC] reeze dot xia at gmail dot com
It's a function but not a class.
We have to use ()to call it
 [2012-06-22 04:19 UTC] Daniel dot L dot Nill at gmail dot com
-Status: Open +Status: Closed
 [2012-06-22 04:19 UTC] Daniel dot L dot Nill at gmail dot com
not sure why closures don't allow variable functions, but it turns out my core 
issue was a versioning issue.  Upon updating php to 5.3.8 this goes away.  Still 
not sure why I was getting a parse error when no arguments where introduced, but 
I'm closing this ticket.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 03:01:28 2024 UTC