PHP pre-defined variable instance detailed

Source: Internet
Author: User
Tags http cookie http post php programming
What is a PHP pre-defined variable?

In PHP programming, often encounter the need to use the address bar information, such as the domain name, access to the URL, url with the parameters of these cases, you can use the predefined variables provided by PHP, through these predefined variables can be obtained such as the user's session, Information such as the user's operating system environment and the local operating system environment. This information is stored in the predefined variable $_server . (Examples of PHP predefined constants are detailed)

Pre-defined variable $_server

$_server is an array of information such as headers, paths, and script locations (scripts locations), so I'll print $_serve and see what $_server is. The code is as follows;

<?phpecho "<pre>";p Rint_r ($_server);? >

The printing results are as follows:

For specific information about the parameter information above, you can refer to PHP full self-study manual: PHP Super global variable.

What are the pre-defined variables for PHP?

The following table is a list of some common predefined variables in PHP. In front of the table are some of the information in the $_server, interested can be compared to the above example to see

The name of the variable Description
$_server[' Server_addr '] The IP address of the server where the script is currently running
$_server[' server_name '] The host name of the server where the script is currently running. If the program is running on a virtual host, the name is determined by the value set by the virtual host
$_server[' Requert_method '] The request method used by the access page. such as Get,head,post,put, if the request is in the way that the head,php script will abort after outputting the header information (this means that no output buffers are available after any output is produced)
$_server[' REMOTE_ADDR '] The IP address of the user browsing the current page
$_server[' Remote_host '] The host name of the user who browsed the current page, and the reverse domain name resolution based on that user's remote_addr
$_server[' Remote_port '] The port number used to connect to the WEB server on the user's machine
$_server[' Script_filename '] The absolute path of the current execution script. Note that if the script is executed in the CLI as a relative path, such as file.php or .../file.php,$_server[' script_filename ') will contain the user-specified relative path
$_server[' Server_port '] The port number of the server where the script is currently running, which is 80 by default, and if SSL secure connection is used, this value is the user-set HTTP port
$_server[' Server_signature '] A string that contains the server version and the virtual host name.
$_server[' Document_root '] The document root directory where the script is currently running. Defined in the server configuration file.
$_cookie An array of variables passed to the current script by means of an HTTP cookie. Most of these cookies are set by the Setcookies () function when the PHP script is executed.
$_session Contains information about all session variables, $_session variables are primarily used for session control and for the delivery of values between pages
$_post Contains information about the parameters passed by the Post method, primarily for obtaining data submitted via the Post method
$_get Contains information about the parameters passed by the Get method, primarily for obtaining data submitted through the Get method
$GLOBALS An array that consists of all defined global variables. The variable name is the index of the array. It can be called the super-set of all the super variables.
$_files An array of items uploaded to the current script via the HTTP POST method
$_request An array of $_get,$_post and $_cookie is included by default.
$_env An array of variables passed to the current script through the environment.
$php _errormsg Previous error message
$HTTP _raw_post_data Native Post data
$http _response_header HTTP response Header
$argc The number of arguments passed to the script
$argv An array of arguments passed to the script

The table above is our PHP pre-defined variables, specifically can see our PHP fully self-study manual, Learning PHP constants and variables, the next section, we understand "PHP constants and variables what is the difference"

Related courses recommended: "Php.cn lonely Nine Cheap (4)-php video tutorial" Predefined variables and constants

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.