get_defined_vars
Returns an array of all defined variables
get_define_vars()
function returns an array containing all defined variables.
Return all defined variables as arrays:
<?php $a = array ( "red" , "green" , "blue" ) ; $arr = get_defined_vars ( ) ; print_r ( $arr [ "a" ] ) ; ?>
Try it yourself
In this example, $a
is an array containing three color strings. After calling get_defined_vars()
, it returns an array $arr
that contains all variables defined in the current scope. Then output the content of $a
variable, i.e. the color array, through print_r($arr["a"])
. Please note that the array key returned get_defined_vars()
is the variable name, and the corresponding value is the value of the variable.
get_defined_vars ( ) ;
none.