PHP如何在匿名函数内访问函数的参数?

I need to access the first argument to a function inside an anonymous function passed as the second argument to said function. For example:

<?php
function a($arg, $func) {
    echo $func();
}
a("argument 1", function () use($arg) {return $arg;});
?>

The above will return the following error:

Notice: Undefined variable: arg in path/to/file.php on line 5

While the desired result would be:

argument 1

Try below solution:

function a($arg, $func) {
    echo $func($arg);
}
a("argument 1", function ($arg) {return $arg;});

output

argument 1

for more detail have a look at http://php.net/manual/en/functions.anonymous.php