Self Executing functions in PHP5.3?

Kireredialm

New Member
I was trying to borrow some programing paradigms from JS to PHP (just for fun).Is there a way of doing:\[code\]$a = (function(){ return 'a';})();\[/code\]I was thinking that with the combination of \[code\]use\[/code\] this can be a nice way to hide variables JS style\[code\]$a = (function(){ $hidden = 'a'; return function($new) use (&$hidden){ $hidden = $new; return $hidden; };})();\[/code\]right now I need to do:\[code\]$temp = function(){....};$a = $temp();\[/code\]It seems pointless...
 
Back
Top