search
Homephp教程php手册php几个预定义变量$_SERVER用法小结

这篇文章主要介绍了php几个预定义变量$_SERVER用法,实例总结了服务器端预定义变量$_SERVER的常见用法,需要的朋友可以参考下

本文实例总结了php几个预定义变量$_SERVER的用法。分享给大家供大家参考。具体如下:

复制代码 代码如下:

echo 'documentroot:'.$_SERVER['DOCUMENT_ROOT'].'
'; //根目录,在apache的配置文件里定义:httpd.conf 比如:DocumentRoot "D:/work/php_root"
echo 'httphost:'.$_SERVER['HTTP_HOST'].'
'; //域名,比如:localhost
echo 'phpself:'.$_SERVER['PHP_SELF'].'
';   // 从根目录到文件本身的路径
echo 'script filename'.$_SERVER['SCRIPT_FILENAME'].'
'; //documentroot+phpself
echo 'request uri'.$_SERVER['REQUEST_URI'].'
'; //从根目录开始所有的URL字符串,包括问号之后的字符
echo 'request method:'.$_SERVER['REQUEST_METHOD'].'
'; //请求的方法
echo 'name:'.$_REQUEST['name'].'
'; //请求参数的值
?>

希望本文所述对大家的PHP程序设计有所帮助。

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools