可以实用 _SERVER变量和_ENV变量
下面是我的phpinfo中的php变量:

_SERVER["SCRIPT_NAME"] 

         /php/index.php
_SERVER["HTTP_COOKIE"]          cdb_sid=tcSZ7o
_SERVER["AUTH_PASSWORD"]        no value
_SERVER["AUTH_TYPE"]            no value
_SERVER["AUTH_USER"]            no value
_SERVER["CONTENT_LENGTH"]       0
_SERVER["CONTENT_TYPE"]         no value
_SERVER["PATH_TRANSLATED"]      c:\inetpub\wwwroot
_SERVER["QUERY_STRING"]        (url中问号后边的部分)
_SERVER["REMOTE_ADDR"]          127.0.0.1
_SERVER["REMOTE_HOST"]          127.0.0.1
_SERVER["REMOTE_USER"]          no value
_SERVER["REQUEST_METHOD"]       GET
_SERVER["SERVER_NAME"]          localhost
_SERVER["SERVER_PORT"]          80
_SERVER["SERVER_PROTOCOL"]      HTTP/1.1
_SERVER["SERVER_SOFTWARE"]      Microsoft-IIS/6.0
_SERVER["APPL_MD_PATH"]         /LM/W3SVC/1/Root/php
_SERVER["APPL_PHYSICAL_PATH"]   E:\web\php\
_SERVER["INSTANCE_ID"]          1
_SERVER["INSTANCE_META_PATH"]   /LM/W3SVC/1
_SERVER["LOGON_USER"]           no value
_SERVER["REQUEST_URI"]          /php/index.php
_SERVER["URL"]                  /php/index.php
_SERVER["SCRIPT_FILENAME"]      E:\web\php\index.php
_SERVER["ORIG_PATH_INFO"]       /php/index.php
_SERVER["PATH_INFO"]            no value
_SERVER["ORIG_PATH_TRANSLATED"]    E:\web\php\index.php
_SERVER["DOCUMENT_ROOT"]        c:\inetpub\wwwroot
_SERVER["PHP_SELF"]             /php/index.php
_SERVER["HTTP_CONNECTION"]      keep-alive
_SERVER["HTTP_KEEP_ALIVE"]      300

_SERVER["HTTP_HOST"]            localhost
_SERVER["HTTP_USER_AGENT"]      Mozilla/5.0 (Windows; U; Windows NT 5.2; zh-CN; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2
_SERVER["REQUEST_TIME"]         1146214357
_SERVER["argv"]

Array
(
)

_SERVER["argc"]                          0
_ENV["ALLUSERSPROFILE"]                  C:\Documents and Settings\All Users
_ENV["ClusterLog"]                       C:\WINDOWS\Cluster\cluster.log
_ENV["CommonProgramFiles"]               C:\Program Files\Common Files
_ENV["COMPUTERNAME"]                     LIUBO
_ENV["ComSpec"]                          C:\WINDOWS\system32\cmd.exe
_ENV["FP_NO_HOST_CHECK"]                 NO
_ENV["NUMBER_OF_PROCESSORS"]             1
_ENV["OS"]                               Windows_NT
_ENV["Path"]                             C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;E:\Program Files\MySQL\MySQL Server 5.0\bin;c:\php;c:\php\ext
_ENV["PATHEXT"]                          .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
_ENV["PROCESSOR_ARCHITECTURE"]           x86
_ENV["PROCESSOR_IDENTIFIER"]             x86 Family 15 Model 4 Stepping 1, GenuineIntel
_ENV["PROCESSOR_LEVEL"]                  15
_ENV["PROCESSOR_REV