<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_21855"> 我在看那个ecmall核心文件ecmall.php,看到这个函数写得比较清晰,拿出来分享下 <br> <br> <br> <div class="blockcode"> <div id="code_Bqi"><ol> <li>function get_domain() {</li> <li> /* 协议 */</li> <li> $protocol = (isset($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) ? 'https://' : 'http://';</li> <li> <li> /* 域名或IP地址 */</li> <li> if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {</li> <li> $host = $_SERVER['HTTP_X_FORWARDED_HOST'];</li> <li> } elseif (isset($_SERVER['HTTP_HOST'])) {</li> <li> $host = $_SERVER['HTTP_HOST'];</li> <li> } else {</li> <li> /* 端口 */</li> <li> if (isset($_SERVER['SERVER_PORT'])) {</li> <li> $port = ':' . $_SERVER['SERVER_PORT'];</li> <li> if ((':80' == $port && 'http://' == $protocol) || (':443' == $port && 'https://' == $protocol)) {</li> <li> $port = '';</li> <li> }</li> <li> } else {</li> <li> $port = '';</li> <li> }</li> <li> <li> if (isset($_SERVER['SERVER_NAME'])) {</li> <li> $host = $_SERVER['SERVER_NAME'] . $port;</li> <li> } elseif (isset($_SERVER['SERVER_ADDR'])) {</li> <li> $host = $_SERVER['SERVER_ADDR'] . $port;</li> <li> }</li> <li> }</li> <li> <li> return $protocol . $host;</li> <li>} </li> </ol></div> <em onclick="copycode($('code_Bqi'));">复制代码</em> </div> </td></tr></table> <div id="comment_21855" class="cm"> </div> <div id="post_rate_div_21855"></div> <br><br>