php获取当前服务器的主机名?
解决方法:
define ('HTTP_HOST', isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']);
补充:当服务器为非80端口时
$_SERVER["HTTP_HOST"] 会输出端口号,例如:yayihouse.com:8080
$_SERVER["SERVER_NAME"] 会直接输出yayihouse.com值,没端口
本文链接:http://www.yayihouse.com/yayishuwu/chapter/1700