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全局变量
本站原创教程,转载注明来源www.111cn.net
*/
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号