PhP9 pre-defined super Global Array

Source: Internet
Author: User
Tags http cookie

Automatic global variable ----- super Global Array

1. contains some arrays related to the Web server, client, runtime environment, and user input data.

2. These arrays are special

3. These arrays can be used directly if they take effect automatically within the global range.

4. Users cannot customize these arrays, but these arrays are operated in the same way as we operate on them.

 

$ _ Get // variable submitted to the script through URL request

The $ _ get super global variable contains information about the parameters passed using the get method. If the request URL is http://www.example.com/index.html? With cat = Apache & id = 157, 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. Get variables cannot be referenced by $ cat or $ id.

 

$ _ Post // variables submitted to the script through the http post request

The $ _ post super global variable contains information about the parameters passed using the POST method. Consider the following form for requesting user information:

 
<Form caction = "subscribe. php"Method= "Post"> <p>Email Address: <Br> <input type = "text" name = "email"Size= "20" maxlength = "so" value = ""> </P> <p>Password: <Br> <input type = "password"Name= "Pswd" size = "20" maxlength = "15"Value= ""> </P> <p> <input type = "Submit" name = "subscribe"Value= "Subscribe! "> </P> </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. The post variable cannot be referenced by $ email, $ pswd, or $ subscribe.

 

$ _ Request // The script variable submitted through the get post COOKIE Mechanism. Therefore, this array is not trustworthy and should not be used.

$ _ 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.

 

$ _ FILES // variables submitted to the script by uploading the http post file

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

 

$ _ 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.

 

$ _ 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.

$ _ Env // variable for script submission in execution environment

 

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

 

$ _ Server // the variables are set by the Web server or directly related to the execution environment of the current script.

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. According to the server, the variable value in the $ _ server and the number of variables will be different, but generally can find the cgi1.1 specification [can be from the U. S. National supercomputer Application Center (http://hoohoo.ncsa.uiuc.edu/cgi/env.html)]. You will find that these variables are applied inProgramAre very useful, including the following items. :

$ _ 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 http://www.example.com/blog/apache/index.html, then uri#/blog/apache/index.html.

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

$ Global // as long as the variables valid for the current script are both here, the array key name is the name of the global variable

The $ globals super global variable array can be considered as a superset of super global variables, including all variables in the global scope. Execute the followingCodeYou can view all variables in $ globals.

$= 1111;FunctionDemo (){$ Global[""];}
 
Print'<PRE>';Print_r($ Globals);Print'</PRE> ';

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.