PHP predefined variable array kind Overview _php tutorial

Source: Internet
Author: User
Tags http cookie

PHP pre-defined variable array 1, $_server

The $_server Super global variable contains information created by the Web server that provides information about the server and client configuration and the current request environment. Depending on the server, the variable value and the number of variables in the $_server are different, but the variables defined in the CGI1.1 specification can generally be found. These include:

$_server[' Http_referer ']; The URL of the page that guides the user to the current location;

$_server[' REMOTE_ADDR ']; Customer IP address;

$_server[' Request_uri ']; The path portion of the URL. 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 pre-defined variable array 2, $_get

The $_get Super global variable contains information about parameters passed using the Get method. If the request URL is [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, the $_get Super global variable is the only way to access the variables passed by the pass get method.

PHP pre-defined variable array 3, $_post

The $_post Super global variable contains information about the parameters passed by 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 = "a" maxlength="So" value="" >
  7. < / P >
  8. < P >
  9. Password: < br >
  10. < input type="password"
  11. name = "PSWD" size= " maxlength"="15"
  12. value = "" >
  13. < / P >
  14. < P >
  15. < input type = "Submit" Name = "Subscribe"
  16. value = "subscribe!" >
  17. < / P >
  18. < /form >

With script subscribe.php, you can use the following post variables:

$_post[' email '] = "jason@example.com";

$_post[' pswd '] = "rainyday";

$_post[' subscribe '] = "subscribe!";

As with $_get, by default, the $_post Super global variable is the only way to access the post variable.

PHP pre-defined variable array 4, $_cookie

The $_cookie Super global variable stores information passed to the script via an HTTP cookie. These cookies are generally set by PHP functions Setcookie (), which were previously executed by PHP scripts. For example, suppose you use Setcookie () to store a cookie named example.com with a value of ab2213. This value can then be obtained by calling $_cookie[' example.com '].

PHP pre-defined variable array 5, $_files

The $_files Super global variable contains information about the data that is uploaded to the server via the Post method. This super global variable differs from the other variables, which is a two-dimensional array that contains 5 elements. The first subscript indicates the file upload element name of the form; The second subscript is one of five predefined subscripts that describe a property of the uploaded file:

$_files[' upload-name ' [' name ']; File name for uploading files from client to server;

$_files[' upload-name ' [' type ']; The MIME type of the uploaded file, whether or not the variable is assigned depends on the browser's functionality.

$_files[' upload-name ' [' Size ']; The size (in bytes) of the uploaded file;

$_files[' upload-name ' [' tmp_name ']; After uploading, move this file to the temporary name given before the final location.

$_files[' upload-name ' [' Error ']; Upload status code. Although the variable is named error, it is actually filled in the case of success. It has five possible values:

UPLOAD_ERR_OK File successfully uploaded

The upload_err_ini_size file size exceeds the maximum value specified by the upload_max_filesize directive.

The upload_err_form_size file size exceeds the maximum value specified by the Max_file_size hidden form field parameter (optional).

Upload_err_partial file only part of the upload

Upload_err_no_file file not specified in upload form

PHP pre-defined variable array 6, $_env

The $_ENV Super global variable provides information about the server environment in which php resolves. The variables in this array include:

$_env[' HOSTNAME ' host name of server

$_env[' shell '] system shell

PHP pre-defined variable array 7, $_request

The $_request Super global variable is a versatile player that records variables passed to the script in various ways, especially get, POST, and COOKIE. The order of these variables does not depend on the order in which they appear in the sending script, but rather depends on the order specified by the Variables_order configuration directives. It is recommended to use this super variable sparingly because it is not secure enough.

PHP pre-defined variable array 8, $_session

The $_session Super global variable contains information about all sessions. Registering session information provides you with the convenience of referencing these session information throughout the site without the need to pass data through a GET or post display.

PHP pre-defined variable array 9, $GLOBALS

The $GLOBALS Super global variable array can be thought of as a superset of the super global variables, including all variables within the global scope. Execute the following code to see all the variables in the $globals.

 
  
  
  1. < Pre > ' ;
  2. Print_r ($GLOBALS);
  3. Pre >



http://www.bkjia.com/PHPjc/446080.html www.bkjia.com true http://www.bkjia.com/PHPjc/446080.html techarticle PHP predefined variable array 1, $_server $_server Super global variable contains information created by the Web server that provides information about the server and client configuration and the current request environment. According to ...

  • 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.