$app = 'app here'; $fn1 = function($var) use($app){ $fn2($var); }; $fn2 = function($var) use($app){ echo $var; }; $fn1('variable'); in above example, trying chain/forward multiple anonymous functions. however, @ below line receive error "notice: undefined variable: fn2"
$fn2($var) how achieve chaining of anonymous functions.
the problem not passing $fn2 parameter in use statement of closure.
try following code:
$app = 'app here'; $fn2 = function($var) use($app){ echo $var; }; $fn1 = function($var) use($app, $fn2){ $fn2($var); }; $fn1('variable');
Comments
Post a Comment