php获取url地址完美代码
<?php function getServerName() { $ServerName = strtolower($_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']); if (strpos($ServerName, 'http://')) { return str_replace('http://', '', $ServerName); } return $ServerName; } //实例调用方法 echo $getServerName; /* 函数说明: strtolower 把字母转换成不写 str_replace 替换指定的内容 strpos 判断字符是否正在指定字符串中 $_SERVER php全局变量 */
永久链接:http://www.phprm.com/code/5d39e0f22a77c72b18d14c7ff8f63186.html
转载随意!带上文章地址吧。