php获取当前url完整地址

//获取当前访问的完整url地址
function getCurUrl() {
    $url = 'http://';
    
    if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') {
        $url = 'https://';
    }
    
    if ($_SERVER['SERVER_PORT'] != '80') {
        $url .= $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . $_SERVER['REQUEST_URI'];
    } else {
        $url .= $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    }
    
    return $url;
}

 

posted @ 2014-04-08 13:55  幻星宇  阅读(198)  评论(0编辑  收藏  举报