Home  >  Article  >  Backend Development  >  Summary of usage of several predefined variables $_SERVER in PHP, summary of _server_PHP tutorial

Summary of usage of several predefined variables $_SERVER in PHP, summary of _server_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:14:52759browse

Usage summary of several predefined variables $_SERVER in php, summary of _server

The examples in this article summarize the usage of several predefined variables $_SERVER in PHP. Share it with everyone for your reference. The details are as follows:

Copy code The code is as follows:
echo 'documentroot:'.$_SERVER['DOCUMENT_ROOT'].'
'; //Root directory, defined in the apache configuration file: httpd.conf For example: DocumentRoot "D:/work/php_root"
echo 'httphost:'.$_SERVER['HTTP_HOST'].'
'; //Domain name, such as: localhost
echo 'phpself:'.$_SERVER['PHP_SELF'].'
'; // The path from the root directory to the file itself
echo 'script filename'.$_SERVER['SCRIPT_FILENAME'].'
'; //documentroot+phpself
echo 'request uri'.$_SERVER['REQUEST_URI'].'
'; //All URL strings starting from the root directory, including the characters after the question mark
echo 'request method:'.$_SERVER['REQUEST_METHOD'].'
'; //Request method
echo 'name:'.$_REQUEST['name'].'
'; //The value of the request parameter
?>

I hope this article will be helpful to everyone’s PHP programming design.

How to output php predefined variables, such as this $_SERVER['SERVER_ADOR']

?
echo - - Just~
If you want to see all the variables under $_SERVER
echo "

";
var_dump($_SERVER);

What are the several predefined global array variables commonly used in PHP?

PHP provides a large number of predefined variables. Detailed documentation is not available as many variables depend on the version and settings of the running server, among other factors. Some predefined variables do not take effect when PHP is run from the command line. Commonly used predefined array variables include $_POST, $_GET, $_REQUEST, $_COOKIE, $_SESSION, $_SERVER, etc. For details, you can refer to the PHP manual, which is very clear.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/907843.htmlTechArticlephp several predefined variables $_SERVER usage summary, _server summary This article summarizes several php predefined variables$ Usage of _SERVER. Share it with everyone for your reference. The details are as follows: Copy code...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn