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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 01:01:35 2025 UTC