PHP Global Variables What is a super global variable

Source: Internet
Author: User
There are many hyper-global variables in PHP, which means they are available in all scopes of a script. There is no need to perform a global $variable in a function or method; You can access them.

These hyper-global variables are:

  • $GLOBALS referencing all variables available in the global scope

  • $_server This hyper-global variable holds information about the header, path, and location of the script.

  • The most important elements that can be accessed in the $_server:

    element/code Description
    $_server[' Php_self '] Returns the file name of the current execution script.
    $_server[' Gateway_interface '] Returns the version of the CGI specification used by the server.
    $_server[' Server_addr '] Returns the IP address of the server where the script is currently running.
    $_server[' server_name '] Returns the host name (such as www.w3school.com.cn) of the server on which the current run script resides.
    $_server[' Server_software '] Returns the server identification string (such as apache/2.2.24).
    $_server[' Server_protocol '] Returns the name and version of the communication protocol when the page is requested (for example, "http/1.0").
    $_server[' Request_method '] Returns the request method used by the access page (for example, POST).
    $_server[' Request_time '] Returns the timestamp at the start of the request (for example, 1577687494).
    $_server[' query_string '] Returns the query string, if this page is accessed through a query string.
    $_server[' Http_accept '] Returns the request header from the current request.
    $_server[' Http_accept_charset '] Returns the Accept_charset header from the current request (for example, utf-8,iso-8859-1)
    $_server[' Http_host '] Returns the Host header from the current request.
    $_server[' Http_referer '] Returns the full URL of the current page (unreliable because it is not supported by all user agents).
    $_server[' HTTPS '] Whether the script is queried through the secure HTTP protocol.
    $_server[' REMOTE_ADDR '] Returns the IP address of the user who browsed the current page.
    $_server[' Remote_host '] Returns the host name of the user who browsed the current page.
    $_server[' Remote_port '] Returns the port number used to connect to the WEB server on the user's machine.
    $_server[' Script_filename '] Returns the absolute path of the current execution script.
    $_server[' Server_admin '] This value indicates the Server_admin parameter in the Apache server configuration file.
    $_server[' Server_port '] The port used by the WEB server. The default value is "80".
    $_server[' Server_signature '] Returns the server version and the virtual host name.
    $_server[' path_translated '] The base path of the file system (not the document root) where the current script resides.
    $_server[' Script_name '] Returns the path of the current script.
    $_server[' Script_uri '] Returns the URI of the current page.
  • $_request is used to collect data submitted by HTML forms.

  • $_post is used to collect form data after submitting an HTML form that submits method= "post". $_post are also commonly used to pass variables.

  • $_get is used to collect form data after the submission of an HTML form (method= "GET").

    $_get can also collect the data sent in the URL.

  • $_files

  • $_env

  • $_cookie

  • $_session

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.