Home > php教程 > php手册 > PHP获取当前完整URL地址的函数,php获取当前url

PHP获取当前完整URL地址的函数,php获取当前url

WBOY
Release: 2016-06-13 09:18:27
Original
1028 people have browsed it

PHP获取当前完整URL地址的函数,php获取当前url

这里主要是给大家分享一个非常实用的PHP函数,代码很简单,就不多废话了,小伙伴们需要的话直接拿去用。

复制代码 代码如下:


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


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template