php 获取网站地址

180it 2020-02-19 AM 2762℃ 0条
/**
 * 获取网站地址
 * @return string 返回网站地址
 */
function getWebUrl() {

    $http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://';   
    $PHP_SELF=$_SERVER['SCRIPT_NAME'];

    $url = $http_type . $_SERVER['SERVER_NAME'] . substr($PHP_SELF,0,strrpos($PHP_SELF,'/')+1);

    return $url;
}

支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

php 获取网站地址