PHP environment variable $

Source: Internet
Author: User
Tags array constant ini variables php script version variable root directory

In the PHP website development, in order to meet the needs of the site, often need to set up and application of PHP environment variables, in the virtual host environment, sometimes we need to use the PHP environment variable operation function to set the value of the PHP environment variables. For this we need to be familiar with the PHP environment variables first. Share some details about PHP environment variables $_server and PHP system constants today.

PHP environment variables are mainly $globals[], $_server[], $_get[], $_post[, $_cookie[, $_files[, $_env[], $_request[, $_session[]. $_get and $_post are primarily for data submitted by Form forms, and $_cookie and $_session are primarily targeted at client-side browser and server session data. $_files mainly for the submission of files uploaded data, $_request mainly for the submission of all the requests in the form array, including $_get, $_post, $_cookie all the content, you can through the Print_r function output $_request or $_ Cookies and more. How does the PHP environment build?

PHP environment variable $_server

is a PHP Global environment variable that contains server-side-related information, which is used before the PHP4.1.0 version of $http_server_vars. More information can be consulted here.

  $_server[' php_self ' is currently executing a script file name that is related to document root. In form forms, such as the execution file is itself, you can use $_server[' php_self ' in the action, and the advantage is that you can not frequently replace the file name in the action if the file name changes.

  $_server[' server_name '] the name of the server host on which the PHP program is currently running.

  $_server[' Request_method '] the request method when accessing the page, that is,, POST and put.

  $_server[' document_root '] the document root directory where the PHP program is currently running. Which is the definition in the php.ini file.

  $_server[' Http_referer ' links to the URL address of the previous page of the current page. is useful in page jump functionality.

  $_server[' REMOTE_ADDR ' is browsing the IP address of the current page visitor.

  $_server[' Remote_host ' is browsing the host name of the user of the current page.

  $_server[' Remote_port '] the port the user is using to connect to the server.

  $_server[' script_filename '] the absolute pathname of the currently executing script.

  Ports used by the $_server[' server_port ' server

  $_server[' Script_name ' contains the path to the current script. This is useful when the page needs to point to itself.

  $_server[' Request_uri '] access the URI required for this page. such as "/index.html".

  $_server[' Php_auth_user ' is applied to the HTTP user logon authentication feature, which is the user input username.

  $_server[' PHP_AUTH_PW ' is used in the HTTP user logon authentication function, this variable is the user input password.

  $_server[' Auth_type ' is used in the HTTP user logon authentication function, this variable is the type of authentication.

  Note : These PHP Global environment variables mentioned above, when the register_globals in PHP.ini is set to ON, are available in all PHP script scripts, that is, the $_server array is separated. Of course, for security reasons, it is better not to open the register_globals.

PHP System Constants

  __file__ The absolute path and file name of the current PHP program script

  __line__ Stores the line number where the constant is located

  __function__ The name of the function where the constant is stored

  __class__ The name of the class where the constant is stored

  Php_version Stores the version number of the current PHP, or it can be obtained by the phpversion () function.

  Php_os Stores the current server's operating system

PHP environment variable $_server More information please refer to the PHP Help manual, the beginning of the article mentioned in the virtual host environment we need to use the PHP environment variable operation function to the PHP environment variable value set, mainly used to Ini_set and ini_get, in fact, there are more such functions, For example, the error reporting settings in PHP, in fact, involves php.ini in the relevant content, have the opportunity to share next time.

  Note : PHP Web Development Tutorials-leapsoul.cn Copyright, reproduced in the form of links to indicate the original source and this statement, thank you.







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.