Current Location: Home> Function Categories> get_defined_vars

get_defined_vars

Returns an array of all defined variables
Name:get_defined_vars
Category:Variable processing
Programming Language:php
One-line Description:Returns all defined variables as array.

Definition and usage

get_define_vars() function returns an array containing all defined variables.

Example

Return all defined variables as arrays:

 <?php
$a = array ( "red" , "green" , "blue" ) ;

$arr = get_defined_vars ( ) ;

print_r ( $arr [ "a" ] ) ;
?>

Try it yourself

Example explanation:

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.

grammar

 get_defined_vars ( ) ;

Parameter value

none.

Similar Functions
Popular Articles