Menu Home

get_defined_vars

osbo.com | PHP | Functions | get_defined_vars

Returns an array of all defined variables

Syntax

get_defined_vars ( void ) : array

Return

A multidimensional array with all the variables.

Examples

1

<?

$return = get_defined_vars();

print_r($return);

?>
Array
(
    [_GET] => Array
        (
        )

    [_POST] => Array
        (
        )

    [_COOKIE] => Array
        (
        )

    [_FILES] => Array
        (
        )

)

2

<?

$variable1 = 0;
$variable2 = 12.34;
$variable3 = "abc";
$variable4 = array(1, 2, 3);

$return = get_defined_vars();

print_r($return);

?>
Array
(
    [_GET] => Array
        (
        )

    [_POST] => Array
        (
        )

    [_COOKIE] => Array
        (
        )

    [_FILES] => Array
        (
        )

    [variable1] => 0
    [variable2] => 12.34
    [variable3] => abc
    [variable4] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
        )

)

PHP