Home/
Manual/
reflection / reflectionfunctionabstract/ ReflectionFunctionAbstract::getClosureUsedVariables
ReflectionFunctionAbstract::getClosureUsedVariables
PHP function
Edit on GitHub ✎
(PHP 8 >= 8.1.0)
Returns an array of the used variables in the Closure
Description
ReflectionFunctionAbstract::getClosureUsedVariables(): array
Returns an Array of the used variables in the Closure.
Parameters Parameters
Return Values
Returns an Array of the used variables in the Closure.
Examples
ReflectionFunctionAbstract::getClosureUsedVariables example
php
<?php
$one = 1;
$two = 2;
$function = function() use ($one, $two) {
static $three = 3;
};
$reflector = new ReflectionFunction($function);
var_dump($reflector->getClosureUsedVariables());
?>The above example will output something similar to:
output
array(2) {
["one"]=>
int(1)
["two"]=>
int(2)
}