海涛的部落格

使用php获取当前页面url

<Category: 随心杂谈> 查看评论
<?php
function get_current_page_url{
    $current_page_url = 'http';
    if ($_SERVER["HTTPS"] == "on") {
        $current_page_url .= "s";
    }
     $current_page_url .= "://";
     if ($_SERVER["SERVER_PORT"] != "80") {
    $current_page_url .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
    } else {
        $current_page_url .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
    }
    return $current_page_url;
}
?>

然后使用 get_current_page_url 就能获取当前页面的 URL。

乐铺活动验证

本文来自: 使用php获取当前页面url

发表评论