Referencing variables from containing scope when using create_function as a closure. PHP

Viewed 463

Using true closures, we can do,

function foo(&$ref)
{
    $inFn = function() use (&$ref)
    {   
        $ref = 42; 
    };  

    $inFn();
}

thus modifying the reference without having to pass it in the call to $inFn.

If we replace,

    $inFn = function(... 

with

    $inFn = create_function(...

is there any (simple and clean) way to do the same thing; refer to a variable of the containing scope by reference without explicitly passing it into $inFn?

3 Answers
Related