Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

get_defined_vars

Description

The get_defined_vars of Variable Handling for PHP returns an array of all defined variables.

Syntax

get_defined_vars(): 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
        (
        )

    [_SERVER] => Array
        (
            [PATH] => /usr/local/bin:/bin:/usr/bin
            [HTTP_CONNECTION] => close
            [HTTP_HOST] => osbo.com
            [HTTP_X_HTTPS] => 1
            [DOCUMENT_ROOT] => /home/osbocom/public_html
            [REMOTE_ADDR] => 212.1.210.80
            [REMOTE_PORT] => 46944
            [SERVER_ADDR] => 212.1.210.80
            [SERVER_NAME] => osbo.com
            [SERVER_ADMIN] => webmaster@osbo.com
            [SERVER_PORT] => 443
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /php/demo/
            [GEOIP_ADDR] => 212.1.210.80
            [GEOIP_CONTINENT_CODE] => NA
            [GEOIP_COUNTRY_CODE] => US
            [GEOIP_COUNTRY_NAME] => United States
            [GEOIP_CITY] => Asheville
            [GEOIP_POSTAL_CODE] => 28801
            [GEOIP_CITY_CONTINENT_CODE] => NA
            [GEOIP_CITY_COUNTRY_CODE] => US
            [GEOIP_CITY_COUNTRY_NAME] => United States
            [GEOIP_REGION] => NC
            [GEOIP_DMA_CODE] => 567
            [GEOIP_LATITUDE] => 35.59470
            [GEOIP_LONGITUDE] => -82.55450
            [GEOIP_ISP] => 47583
            [GEOIP_ORGANIZATION] => Hostinger International Limited
            [HTTPS] => on
            [CRAWLER_USLEEP] => 1000
            [CRAWLER_LOAD_LIMIT_ENFORCE] => 20
            [SSL_PROTOCOL] => TLSv1.3
            [SSL_CIPHER] => TLS_AES_256_GCM_SHA384
            [SSL_CIPHER_USEKEYSIZE] => 256
            [SSL_CIPHER_ALGKEYSIZE] => 256
            [SCRIPT_FILENAME] => /home/osbocom/public_html/php/demo/index.php
            [QUERY_STRING] => 
            [SCRIPT_URI] => https://osbo.com/php/demo/
            [SCRIPT_URL] => /php/demo/
            [SCRIPT_NAME] => /php/demo/index.php
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SOFTWARE] => LiteSpeed
            [REQUEST_METHOD] => GET
            [X-LSCACHE] => on,crawler
            [PHP_SELF] => /php/demo/index.php
            [REQUEST_TIME_FLOAT] => 1728986259.2064
            [REQUEST_TIME] => 1728986259
        )

)

2

<?

$array = array(true, 12.34, "abc", array(0, 1));

$return = get_defined_vars();

print_r($return);

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

    [_POST] => Array
        (
        )

    [_COOKIE] => Array
        (
        )

    [_FILES] => Array
        (
        )

    [_SERVER] => Array
        (
            [PATH] => /usr/local/bin:/bin:/usr/bin
            [HTTP_CONNECTION] => close
            [HTTP_HOST] => osbo.com
            [HTTP_X_HTTPS] => 1
            [DOCUMENT_ROOT] => /home/osbocom/public_html
            [REMOTE_ADDR] => 212.1.210.80
            [REMOTE_PORT] => 46950
            [SERVER_ADDR] => 212.1.210.80
            [SERVER_NAME] => osbo.com
            [SERVER_ADMIN] => webmaster@osbo.com
            [SERVER_PORT] => 443
            [REQUEST_SCHEME] => https
            [REQUEST_URI] => /php/demo/
            [GEOIP_ADDR] => 212.1.210.80
            [GEOIP_CONTINENT_CODE] => NA
            [GEOIP_COUNTRY_CODE] => US
            [GEOIP_COUNTRY_NAME] => United States
            [GEOIP_CITY] => Asheville
            [GEOIP_POSTAL_CODE] => 28801
            [GEOIP_CITY_CONTINENT_CODE] => NA
            [GEOIP_CITY_COUNTRY_CODE] => US
            [GEOIP_CITY_COUNTRY_NAME] => United States
            [GEOIP_REGION] => NC
            [GEOIP_DMA_CODE] => 567
            [GEOIP_LATITUDE] => 35.59470
            [GEOIP_LONGITUDE] => -82.55450
            [GEOIP_ISP] => 47583
            [GEOIP_ORGANIZATION] => Hostinger International Limited
            [HTTPS] => on
            [CRAWLER_USLEEP] => 1000
            [CRAWLER_LOAD_LIMIT_ENFORCE] => 20
            [SSL_PROTOCOL] => TLSv1.3
            [SSL_CIPHER] => TLS_AES_256_GCM_SHA384
            [SSL_CIPHER_USEKEYSIZE] => 256
            [SSL_CIPHER_ALGKEYSIZE] => 256
            [SCRIPT_FILENAME] => /home/osbocom/public_html/php/demo/index.php
            [QUERY_STRING] => 
            [SCRIPT_URI] => https://osbo.com/php/demo/
            [SCRIPT_URL] => /php/demo/
            [SCRIPT_NAME] => /php/demo/index.php
            [SERVER_PROTOCOL] => HTTP/1.1
            [SERVER_SOFTWARE] => LiteSpeed
            [REQUEST_METHOD] => GET
            [X-LSCACHE] => on,crawler
            [PHP_SELF] => /php/demo/index.php
            [REQUEST_TIME_FLOAT] => 1728986259.2939
            [REQUEST_TIME] => 1728986259
        )

    [array] => Array
        (
            [0] => 1
            [1] => 12.34
            [2] => abc
            [3] => Array
                (
                    [0] => 0
                    [1] => 1
                )

        )

)

3

<?

$array = array(true, 12.34, "abc", array(0, 1));

$return = get_defined_vars();

print_r($return["array"]);

?>
Array
(
    [0] => 1
    [1] => 12.34
    [2] => abc
    [3] => Array
        (
            [0] => 0
            [1] => 1
        )

)

4

<?

$return = get_defined_vars();

print_r($return["_SERVER"]);

?>
Array
(
    [PATH] => /usr/local/bin:/bin:/usr/bin
    [HTTP_CONNECTION] => close
    [HTTP_HOST] => osbo.com
    [HTTP_X_HTTPS] => 1
    [DOCUMENT_ROOT] => /home/osbocom/public_html
    [REMOTE_ADDR] => 212.1.210.80
    [REMOTE_PORT] => 46960
    [SERVER_ADDR] => 212.1.210.80
    [SERVER_NAME] => osbo.com
    [SERVER_ADMIN] => webmaster@osbo.com
    [SERVER_PORT] => 443
    [REQUEST_SCHEME] => https
    [REQUEST_URI] => /php/demo/
    [GEOIP_ADDR] => 212.1.210.80
    [GEOIP_CONTINENT_CODE] => NA
    [GEOIP_COUNTRY_CODE] => US
    [GEOIP_COUNTRY_NAME] => United States
    [GEOIP_CITY] => Asheville
    [GEOIP_POSTAL_CODE] => 28801
    [GEOIP_CITY_CONTINENT_CODE] => NA
    [GEOIP_CITY_COUNTRY_CODE] => US
    [GEOIP_CITY_COUNTRY_NAME] => United States
    [GEOIP_REGION] => NC
    [GEOIP_DMA_CODE] => 567
    [GEOIP_LATITUDE] => 35.59470
    [GEOIP_LONGITUDE] => -82.55450
    [GEOIP_ISP] => 47583
    [GEOIP_ORGANIZATION] => Hostinger International Limited
    [HTTPS] => on
    [CRAWLER_USLEEP] => 1000
    [CRAWLER_LOAD_LIMIT_ENFORCE] => 20
    [SSL_PROTOCOL] => TLSv1.3
    [SSL_CIPHER] => TLS_AES_256_GCM_SHA384
    [SSL_CIPHER_USEKEYSIZE] => 256
    [SSL_CIPHER_ALGKEYSIZE] => 256
    [SCRIPT_FILENAME] => /home/osbocom/public_html/php/demo/index.php
    [QUERY_STRING] => 
    [SCRIPT_URI] => https://osbo.com/php/demo/
    [SCRIPT_URL] => /php/demo/
    [SCRIPT_NAME] => /php/demo/index.php
    [SERVER_PROTOCOL] => HTTP/1.1
    [SERVER_SOFTWARE] => LiteSpeed
    [REQUEST_METHOD] => GET
    [X-LSCACHE] => on,crawler
    [PHP_SELF] => /php/demo/index.php
    [REQUEST_TIME_FLOAT] => 1728986259.4772
    [REQUEST_TIME] => 1728986259
)
HomeMenu