Home  >  Article  >  Backend Development  >  第二章 二/3 PHP的外部变量、环境变量、表达式

第二章 二/3 PHP的外部变量、环境变量、表达式

WBOY
WBOYOriginal
2016-06-13 10:55:17728browse

第二章 2/3 PHP的外部变量、环境变量、表达式
1. 外部变量
$_GET、$_POST、$_REQUEST
$_FILES、$_COOKIE、$_SESSION

print_r($_GET);// 打印所有提交的表单含有name属性的值
echo $_GET["username"];
echo $_POST["username"];
或者
echo $username;// 无论是post还是get传值,可以直接用$加上变量名
2. 环境变量
$_SERVER和$_ENV
print_r($_SERVER);
echo $_SERVER["remote_addr"];// 获取客户端地址
echo $_SERVER["DOCUMENT_ROOT"];// 工作目录
echo $_SERVER["SCRIPT_FILENAME"];// 当前脚本名
print_r($_ENV);// 所有值都包含在phpinfo()里边

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