php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #63006 call just defined anonymous function
Submitted: 2012-09-04 07:10 UTC Modified: 2014-10-12 15:07 UTC
Votes:2
Avg. Score:2.0 ± 1.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: printercu at gmail dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.4Git-2012-09-04 (Git) OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: printercu at gmail dot com
New email:
PHP Version: OS:

 

 [2012-09-04 07:10 UTC] printercu at gmail dot com
Description:
------------
It would be useful to call just defined anonymous function to get private 
variable scope like this:

$bar = 1;
...
$foo = (function()
{
  $bar = [1, 2, 3];
  $bar[ 'sum' ] = array_sum( $bar );
  return $bar;
})();

# $bar is unchanged



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-10-12 15:07 UTC] nikic@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2014-10-12 15:07 UTC] nikic@php.net
Supported in PHP 7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 07:01:32 2024 UTC