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
 [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 18:01:35 2024 UTC