PHP获取客户端URL信息
//测试地址
$url = 'http://192.168.1.111:80/time/url.php?moudle=5&id=666';
//获取http协议
$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';
echo $http_type."<br>"; #http://
//获取域名或主机地址
echo $_SERVER['HTTP_HOST']."<br>"; #192.168.1.111
//获取网页地址
echo $_SERVER['PHP_SELF']."<br>"; #/blog/testurl.php
//获取网址参数
echo $_SERVER["QUERY_STRING"]."<br>"; #moudle=5&id=666
//获取用户代理
$HTTP_REFERER = isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:'null';
echo $HTTP_REFERER."<br>"; #null
//获取完整的url
echo $http_type.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']."<br>";
echo $http_type.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']."<br>";
#http://192.168.1.111/time/url.php?moudle=5&id=666
//包含端口号的完整url
echo $http_type.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]."<br>";
#http://192.168.1.111:80/time/url.php?moudle=5&id=666
//只取路径
$url='http://'.$_SERVER['SERVER_NAME'].$_SERVER["REQUEST_URI"];
echo dirname($url); #http://192.168.1.111/time
获取系统类型及版本号: php_uname() (例:Windows NT COMPUTER 5.1 build 2600)
只获取系统类型: php_uname(‘s’) (或:PHP_OS,例:Windows NT)
只获取系统版本号: php_uname(‘r’)
获取PHP运行方式: php_sapi_name() (PHP run mode:apache2handler)
获取前进程用户名: Get_Current_User()
获取PHP版本: PHP_VERSION
获取Zend版本: Zend_Version()
获取PHP安装路径: DEFAULT_INCLUDE_PATH
获取当前文件绝对路径: FILE
获取Http请求中Host值: $_SERVER[“HTTP_HOST”] (返回值为域名或IP)
获取服务器IP: GetHostByName($_SERVER[‘SERVER_NAME’])
接受请求的服务器IP: $_SERVER[“SERVER_ADDR”] (有时候获取不到,推荐用:GetHostByName($_SERVER[‘SERVER_NAME’]))
获取客户端IP: $_SERVER[‘REMOTE_ADDR’]
获取服务器解译引擎: $_SERVER[‘SERVER_SOFTWARE’]
获取服务器CPU数量: $_SERVER[‘PROCESSOR_IDENTIFIER’]
获取服务器系统目录: $_SERVER[‘SystemRoot’]
获取服务器域名:$_SERVER[‘SERVER_NAME’] (建议使用:$_SERVER[“HTTP_HOST”])
获取用户域名: $_SERVER[‘USERDOMAIN’]
获取服务器语言: $_SERVER[‘HTTP_ACCEPT_LANGUAGE’]
获取服务器Web端口: $_SERVER[‘SERVER_PORT’]