dev.mraj dev.mraj - 1 year ago 88
PHP Question

Calling Nested Lamda Function in PHP

is that possible to call lamda function in nesting way

$func=function() use($something,$func /** as you know it will be undefined so what could be other way arround**/){

Answer Source

$func is not defined yet when you pass it to $func. $func will only be defined right after the function definition, which is a little bit too late for this to work.

The easy work around is as follows:

$func = null;
$func = function() use (&$func) {

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download