php中全局变量列表:
$GLOBALS $_SERVER $_REQUEST $_POST $_GET $_FILES $_ENV $_COOKIE $_SESSION |
1、$GLOBALS可将$GLOBALS['a']中php变量a转化成全局变量!
例如:
<?php $x = 75; $y = 25; function addition() { $GLOBALS [ 'z' ] = $GLOBALS [ 'x' ] + $GLOBALS [ 'y' ]; } addition(); echo $z ; ?> |
2、$_SERVER 这种超全局变量保存关于报头、路径和脚本位置的信息。
例如:
<?php echo $_SERVER [ 'PHP_SELF' ]; echo "<br>" ; echo $_SERVER [ 'SERVER_NAME' ]; echo "<br>" ; echo $_SERVER [ 'HTTP_HOST' ]; echo "<br>" ; echo $_SERVER [ 'HTTP_REFERER' ]; echo "<br>" ; echo $_SERVER [ 'HTTP_USER_AGENT' ]; echo "<br>" ; echo $_SERVER [ 'SCRIPT_NAME' ]; ?> |
3、PHP $_REQUEST 用于收集 HTML 表单提交的数据。用法同$_GET和$_POST一模一样;