Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<ReflectionFunctionAbstract::getClosureThisReflectionFunctionAbstract::getDocComment>
^ReflectionFunctionAbstractLast updated: Mon, 26 Oct 2026

ReflectionFunctionAbstract::getClosureUsedVariables

(PHP 8 >= 8.1.0)

ReflectionFunctionAbstract::getClosureUsedVariables — Returns an array of the used variables in the Closure

Description

public function ReflectionFunctionAbstract::getClosureUsedVariables(): array

Returns an array of the used variables in the Closure.

Parameters

This function has no parameters.

Return Values

Returns an array of the used variables in the Closure.

Examples

Example #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());
?>

The above example will output something similar to:

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

See Also


<ReflectionFunctionAbstract::getClosureThisReflectionFunctionAbstract::getDocComment>
^ReflectionFunctionAbstractLast updated: Mon, 26 Oct 2026