Req #63006 [Opn->Csd]: call just defined anonymous function

From: Date: Sun, 12 Oct 2014 15:07:38 +0000
Subject: Req #63006 [Opn->Csd]: call just defined anonymous function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-188040@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63006&edit=1 ID: 63006 Updated by: nikic@php.net Reported by: printercu at gmail dot com Summary: call just defined anonymous function -Status: Open +Status: Closed Type: Feature/Change Request Package: Scripting Engine problem Operating System: any PHP Version: 5.4Git-2012-09-04 (Git) -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: Supported in PHP 7. Previous Comments: ------------------------------------------------------------------------ [2012-09-04 07:10:33] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63006&edit=1

« previous php.bugs (#188040) next »