PHP预定义变量

  
    echo $_SERVER['PHP_SELF'],"
"
;//输入执行当前脚本的文件名 echo $_SERVER['DOCUMENT_ROOT'],"
"
;//获取网站根目录 echo $_SERVER['SERVER_ADDR'],"
"
;//返回运行当前脚本的服务器的IP,如果是本机就是127.0.0.1 echo $_SERVER['SERVER_NAME'],"
"
;//服务器主机名称 echo $_SERVER['SERVER_PORT'],"
"
;//服务器主机端口 echo $_SERVER['SERVER_SIGNATURE'],"
"
;//包含服务器版本和虚拟主机字符串 echo $_SERVER['REQUEST_METHOD'],"
"
;//访问页面时的请求方法(GET HEAD POST PUT) echo $_SERVER['REMOTE_ADDR'],"
"
;//返回浏览当前页面的用户的IP地址 /* 函数 getenv : Gets the value of an environment variable(得到各种环境变量的值), 返回值: Returns the value of the environment variable varname, or FALSE on an error(失败的话返回 FALSE) */ getenv('REMOTE_ADDR'); //这个函数也是返回浏览当前页面的用户的IP地址 echo $_SERVER['REMOTE_HOST'],"
"
;//正在浏览当前页面的用户的主机名,反向解析'SERVER_ADDR' echo $_SERVER['REMOTE_PORT'],"
"
;//正在浏览当前页面的用户的主机端口 echo $_SERVER['SCRIPT_FILENAME'],"
"
;//当前执行脚本的绝对路径 echo $_COOKIE,"
"
;//通过HTTP COOKIE传递到脚本的信息 echo $_SESSION,"
"
;//包含与所有会话有关的信息 echo $_POST,"
"
;//包含通过post方法传递参数的信息 echo $_GET,"
"
;//包含通过get方法传递参数的信息 $zy="123456"; $zzy="1234567"; $GLOBALS['zy'] = "123456"; global $zzy; echo $GLOBALS,"
"
;//有所有一定以全局变量组成的数组 ?>
/array.php
D:/PHP/testApp
127.0.0.1
localhost
8080

GET
127.0.0.1

53226
D:/PHP/testApp/array.php
Array

Array
Array
Array


    function test() {
        $foo = "local variable";
        echo '$foo in global scope: ' . $GLOBALS["foo"] . "
"
; echo '$foo in current scope: ' . $foo . "
"
; } $foo = "Example content
"
; test(); ?>
$foo in global scope: Example content

$foo in current scope: local variable

你可能感兴趣的:(PHP)