本文主要是介绍php中$_SERVER['HTTP_HOST']和$_SERVER['SERVER_NAME']的区别,记不住来看看就知道了,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
$_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME']:$_SERVER['SERVER_PORT']当URL为:http://www.tomener.com/love.php
$_SERVER['HTTP_HOST']输出是:www.tomener.com
$_SERVER['SERVER_NAME']输出是:www.tomener.com
为什么一样,因为默认端口是:80 ,http_host就把它省略了!实际是:
$_SERVER['HTTP_HOST'] = www.tomener.com:80
而
$_SERVER['SERVER_NAME'] = www.tomener.com
所以,
$_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME']:$_SERVER['SERVER_PORT']
这篇关于php中$_SERVER['HTTP_HOST']和$_SERVER['SERVER_NAME']的区别,记不住来看看就知道了的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!