ReflectionFunctionAbstract::getClosureUsedVariables

(PHP 8 >= 8.1.0)

ReflectionFunctionAbstract::getClosureUsedVariablesReturns an array of the used variables in the Closure

说明

publicReflectionFunctionAbstract::getClosureUsedVariables(): array

Returns an array of the used variables in the Closure.

参数

此函数没有参数。

返回值

Returns an array of the used variables in the Closure.

示例

示例 #1 ReflectionFunctionAbstract::getClosureUsedVariables() example

<?php

$one
= 1;
$two = 2;

$function = function() use ($one, $two) {
static
$three = 3;
};

$reflector = new ReflectionFunction($function);

var_dump($reflector->getClosureUsedVariables());
?>

以上示例的输出类似于:

array(2) { ["one"]=> int(1) ["two"]=> int(2) }

参见

To Top