<?php function getFullUrl(){ # 解决通用问题 $requestUri = ‘‘; if (isset($_SERVER[‘REQUEST_URI‘])) { #$_SERVER["REQUEST_URI"] 只有 apache 才支持, $requestUri = $_SERVER[‘REQUEST_URI‘]; } else { if (isset($_SERVER[‘argv‘])) { $requestUri = $_SERVER[‘PHP_SELF‘] .‘?‘. $_SERVER[‘argv‘][0]; } else if(isset($_SERVER[‘QUERY_STRING‘])) { $requestUri = $_SERVER[‘PHP_SELF‘] .‘?‘. $_SERVER[‘QUERY_STRING‘]; } } // echo $requestUri.‘<br />‘; $scheme = empty($_SERVER["HTTPS"]) ? ‘‘ : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strstr(strtolower($_SERVER["SERVER_PROTOCOL"]), "/",true) . $scheme; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); # 获取的完整url $_fullUrl = $protocol . "://" . $_SERVER[‘SERVER_NAME‘] . $port . $requestUri; return $_fullUrl; } echo getFullUrl();
时间: 2024-11-07 00:35:28