phpday 2027 - Call for Papers

ReflectionFunctionAbstract::getClosureUsedVariables

(PHP 8 >= 8.1.0)

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

Descrizione

public function ReflectionFunctionAbstract::getClosureUsedVariables(): array

Returns an array of the used variables in the Closure.

Elenco dei parametri

Questa funzione non ha parametri.

Valori restituiti

Returns an array of the used variables in the Closure.

Esempi

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

Il precedente esempio visualizzerà qualcosa di simile a:

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

Vedere anche:

+add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top