kpengfang / PHP / 如何用php的环境变量得到一个网页地址的内...

分享

   

如何用php的环境变量得到一个网页地址的内容?ip地址又要怎样得到?

2015-06-08  kpengfang

结果:echo $_SERVER ["PHP_SELF"];echo $_SERVER ["SERVER_ADDR"];方法之一:

echo "

";

print_r($_SERVER);

?>

输出:

Array

(

[HTTP_HOST] => localhost

[HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0

[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

[HTTP_ACCEPT_LANGUAGE] => zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3

[HTTP_ACCEPT_ENCODING] => gzip, deflate

[HTTP_CONNECTION] => keep-alive

[HTTP_CACHE_CONTROL] => max-age=0

[PATH] => C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;

[SystemRoot] => C:\Windows

[COMSPEC] => C:\Windows\system32\cmd.exe

[PATHEXT] => .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC

[WINDIR] => C:\Windows

[SERVER_SIGNATURE] =>

[SERVER_SOFTWARE] => Apache/2.2.6 (Win32) PHP/5.2.5

[SERVER_NAME] => localhost

[SERVER_ADDR] => 127.0.0.1

[SERVER_PORT] => 80

[REMOTE_ADDR] => 127.0.0.1

[DOCUMENT_ROOT] => D:/wamp/www

[SERVER_ADMIN] => webmaster@localhost

[SCRIPT_FILENAME] => D:/wamp/www/index.php

[REMOTE_PORT] => 54001

[GATEWAY_INTERFACE] => CGI/1.1

[SERVER_PROTOCOL] => HTTP/1.1

[REQUEST_METHOD] => GET

[QUERY_STRING] =>

[REQUEST_URI] => /index.php

[SCRIPT_NAME] => /index.php

[PHP_SELF] => /index.php

[REQUEST_TIME] => 1381126174

[argv] => Array

(

)

[argc] => 0)答案:echo $_SERVER ["PHP_SELF"];echo $_SERVER ["SERVER_ADDR"];


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。

    来自: kpengfang > 《PHP》

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多
    喜欢该文的人也喜欢 更多

    ×
    ×

    ¥.00

    微信或支付宝扫码支付:

    开通即同意《个图VIP服务协议》

    全部>>