Php global variables over global variables, php global variables

Source: Internet
Author: User

Php global variables over global variables, php global variables

Php has many super global variables, which means they are available in all scopes of a script. You can access functions or methods without performing global $ variable.

These super global variables are:

  • $ GLOBALS references all variables available in the global scope
  • The $ _ SERVER super global variable stores information about the header, path, and script location.
  • The most important element that can be accessed in $ _ SERVER:

    Element/code Description
    $ _ SERVER ['php _ SELF '] Returns the file name of the currently executed script.
    $ _ SERVER ['Gateway _ interface'] Return the CGI standard version 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 (for example, www.w3school.com.cn) of the server where the script is currently running ).
    $ _ SERVER ['server _ soft'] Returns the server ID string (for example, Apache/2.2.24 ).
    $ _ SERVER ['server _ Protocol'] The name and version of the communication protocol when the request page is returned (for example, "HTTP/1.0 ").
    $ _ SERVER ['request _ method'] Return the request method used to access the page (for example, POST ).
    $ _ SERVER ['request _ time'] Returns the start timestamp of the request (for example, 1577687494 ).
    $ _ SERVER ['query _ string'] Returns the query string. If the query string is used to access this page.
    $ _ SERVER ['HTTP _ ACCEPT '] Returns the request header from the current request.
    $ _ SERVER ['HTTP _ accept_charset'] Returns the Accept_Charset header from the current request (e.g. UTF-8, ISO-8859-1)
    $ _ SERVER ['HTTP _ host'] Returns the Host header from the current request.
    $ _ SERVER ['HTTP _ referer'] Returns the complete URL of the current page (unreliable because not all user proxies support it ).
    $ _ SERVER ['https'] Whether to use the security HTTP protocol to query scripts.
    $ _ SERVER ['remote _ ADDR '] Returns the IP address of the user browsing the current page.
    $ _ SERVER ['remote _ host'] Returns the host name of the user browsing the current page.
    $ _ SERVER ['remote _ port'] Return the port number used to connect to the Web server on your machine.
    $ _ SERVER ['script _ filename'] Returns the absolute path of the currently executed script.
    $ _ SERVER ['server _ admin'] This value specifies 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 virtual host name.
    $ _ SERVER ['path _ TRANSLATED '] The basic path of the file system (non-document root directory) where the current script is located.
    $ _ 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 the form data after the HTML form submitted by method = "post. $ _ POST is also used to pass variables.
  • $ _ GET is used to collect the form data after the HTML form (method = "get") is submitted.

    $ _ GET can also collect data sent from URLs.

  • $ _ FILES
  • $ _ ENV
  • $ _ COOKIE
  • $ _ SESSION

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.