Some predefined variables in php $ _ SERVER usage summary and _ server Summary

Source: Internet
Author: User

Some predefined variables in php $ _ SERVER usage summary and _ server Summary

This example summarizes the usage of several predefined variables $ _ SERVER in php. Share it with you for your reference. The details are as follows:

Copy codeThe Code is as follows: <? Php
Echo 'documentroot :'. $ _ SERVER ['document _ root']. '<br>'; // root directory, defined in the apache configuration file: httpd. conf For example: DocumentRoot "D:/work/php_root"
Echo 'httphost: '. $ _ SERVER ['HTTP _ host'].' <br> '; // domain name, such as: localhost
Echo 'phpself: '. $ _ SERVER ['php _ SELF']. '<br>'; // path from the root directory to the file itself
Echo 'script filename'. $ _ SERVER ['script _ filename']. '<br>'; // documentroot + phpself
Echo 'request uri '. $ _ SERVER ['request _ URI']. '<br>'; // All URL strings starting from the root directory, including characters after the question mark
Echo 'request method: '. $ _ SERVER ['request _ method'].' <br> '; // request METHOD
Echo 'name: '. $ _ REQUEST ['name'].' <br> '; // value of the REQUEST Parameter
?>

I hope this article will help you with PHP programming.


How to output php pre-defined variables, such as $ _ SERVER ['server _ ador']

?
Echo--OK ~
If you want to see all the variables under $ _ SERVER
Echo "<pre> ";
Var_dump ($ _ SERVER );

Which of the following predefined Global Array variables are commonly used in PHP?

PHP provides a large number of predefined variables. Because many variables depend on the version and settings of the running server, and other factors, there is no detailed description document. Some predefined variables do not take effect when PHP is run as a command line. Common pre-defined array variables include $ _ POST, $ _ GET, $ _ REQUEST, $ _ COOKIE, $ _ SESSION, and $ _ SERVER. For more information, see the php manual, the above is clearly written.
 

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.