时间:2021-07-01 10:21:17 帮助过:24人阅读
function get_http(){    return isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 'https://' : 'http://';}function get_domain(){    $protocol = get_http();    if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {        $host = $_SERVER['HTTP_X_FORWARDED_HOST'];    } elseif (isset($_SERVER['HTTP_HOST'])) {        $host = $_SERVER['HTTP_HOST'];    } else {        if (isset($_SERVER['SERVER_PORT'])) {            $port = ':' . $_SERVER['SERVER_PORT'];            if (':80' == $port && 'http://' == $protocol || ':443' == $port && 'https://' == $protocol) {                $port = '';            }        } else {            $port = '';        }        if (isset($_SERVER['SERVER_NAME'])) {            $host = $_SERVER['SERVER_NAME'] . $port;        } elseif (isset($_SERVER['SERVER_ADDR'])) {            $host = $_SERVER['SERVER_ADDR'] . $port;        }    }    return $protocol . $host;}  
  ip地址/css/index.css  
  
 这里不是应该ip地址 :8080/css/index.css 
   ip地址/css/index.css   
   
 这里不是应该ip地址 :8080/css/index.css  
   ip地址/css/index.css   
   
 这里不是应该ip地址 :8080/css/index.css  
那什?情?下?使用IP???
那什?情?下?使用IP???
这个不确定,网站的首页有10分钟的缓存,会在10分钟过后重新缓存,有时候访问访问着样式就乱了,所以才猜有可能是服务器不稳当  你的网站会是在 http 和 https 间切换吗?  
 只有在发生切换时才需要产生完整的 url  
  
 你 12 行起的,处理端口的代码在什么情况下会执行呢?($_SERVER['HTTP_HOST'] 总是存在的)  
 处理端口(PORT)和处理 HOST 是平行的,不应该放在 else 分支中 
谢谢版主热心回答