PHP predefined variable array type Overview

Source: Internet
Author: User
Tags http cookie

PHP predefined variable array 1, $ _ SERVER

The $ _ SERVER super global variable contains information created by the web SERVER. It provides information about the SERVER and the customer configuration and the current request environment. The variable values in $ _ SERVER differ from the number of variables on the SERVER. However, variables defined in CGI1.1 can be found generally. Including:

$ _ SERVER ['HTTP _ referer']; The URL that directs the user to the page at the current location;

$ _ SERVER ['remote _ ADDR ']; customer IP address;

$ _ SERVER ['request _ URI ']; URL path. If the URL is [url] http://www.example.com/blog/apache/index.html#/url], then the URI is/blog/apache/index.html.

$ _ SERVER ['HTTP _ USER_AGENT ']; the customer's user agent generally provides information about the operating system and the browser.

PHP predefined variable array 2, $ _ GET

The $ _ GET super global variable contains information about the parameters passed using the GET method. If the requested URL is a [url] http://www.example.com/index.html? Cat = apache & id = 157 [/url], you can use the $ _ GET super global variable to access the following variables:

$ _ GET ['cat'] = "apache ";

$ _ GET ['id'] = "157 ";

By default, $ _ GET is the only way to access the variables passed through the GET method.

PHP predefined variable array 3, $ _ POST

The $ _ POST super global variable contains information about the parameters passed using the POST method.

 
 
  1. < form caction="subscribe.php" 
  2. method = "post"> 
  3. < p> 
  4. Email address : < br> 
  5. < input type="text" name="email" 
  6. size="20" maxlength="so" value=""> 
  7. < /p> 
  8. < p> 
  9. Password : < br> 
  10. < input type="password" 
  11. name="pswd" size="20" maxlength="15" 
  12. value=""> 
  13. < /p> 
  14. < p> 
  15. < input type="submit" name="subscribe" 
  16. value="subscribe!"> 
  17. < /p> 
  18. < /form> 

By using the script subscribe. php, you can use the following POST variable:

$ _ POST ['e-mail '] = "jason@example.com ";

$ _ POST ['pswd '] = "rainyday ";

$ _ POST ['subscribe'] = "subscribe! ";

Like $ _ GET, $ _ POST is the only way to access the POST variable by default.

PHP predefined variable array 4, $ _ COOKIE

$ _ COOKIE the super global variable stores the information transmitted to the script through HTTP cookie. These cookies are generally set by the setcookie () function of the previously executed PHP script. For example, if setcookie () is used to store a cookie named example.com with a value of ab2213. You can obtain this value by calling $ _ COOKIE ['example.com.

PHP predefined variable array 5, $ _ FILES

The $ _ FILES super global variable contains information about the data uploaded to the server through the POST method. This super global variable is different from other variables. It is a two-dimensional array containing five elements. The first subscript indicates the name of the file upload element in the form. The second subscript is one of the five pre-defined subscripts, which describe a property of the file to be uploaded:

$ _ FILES ['upload-name'] ['name']; file name uploaded from the client to the server;

$ _ FILES ['upload-name'] ['type']; MIME type of the uploaded file. Whether the value of this variable is assigned depends on the function of the browser.

$ _ FILES ['upload-name'] ['SIZE']; size of the uploaded file (in bytes );

$ _ FILES ['upload-name'] ['tmp _ name']; temporary name assigned before the file is uploaded to the final location.

$ _ FILES ['upload-name'] ['error']; upload status code. Although this variable is named error, it will be filled in if it is successful. It has five possible values:

UPLOAD_ERR_ OK File Uploaded successfully

The size of the UPLOAD_ERR_INI_SIZE file exceeds the maximum value specified by the upload_max_filesize command.

The size of the UPLOAD_ERR_FORM_SIZE file exceeds the maximum value specified by MAX_FILE_SIZE to hide the form field parameter (optional.

Only part of the UPLOAD_ERR_PARTIAL file is uploaded.

No file specified in the UPLOAD_ERR_NO_FILE upload form

PHP predefined variable array 6, $ _ ENV

The $ _ ENV super global variable provides PHP to parse information about the server environment. The variables in this array include:

$ _ ENV ['hostname'] server host name

$ _ ENV ['shell'] System SHELL

PHP predefined variable array 7, $ _ REQUEST

$ _ REQUEST is an all-powerful global variable that records the variables passed to the script through various methods, especially GET, POST, and COOKIE. The order of these variables does not depend on the order they appear in the sending script, but on the order specified by the variables_order configuration command. We recommend that you use this super variable because it is not safe enough.

PHP predefined variable array 8, $ _ SESSION

The $ _ SESSION super global variable contains information related to all sessions. Registering session information can be convenient for you, so that you can reference the session information throughout the website without passing data through the GET or POST display.

PHP pre-defined variable array 9, $ GLOBALS

The $ GLOBALS super global variable array can be considered as a superset of super global variables, including all variables in the global scope. Run the following code to view all the variables in $ GLOBALS.

 
 
  1. print ' <pre>' ;  
  2. print_r ($GLOBALS);  
  3. print ' </pre>' ; 


 


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.