How to Get Current Browser URL in php?

This question already has an answer here:

  • Get the full URL in PHP 28 answers

  • $_SERVER['REQUEST_URI']
    

    For more details on what info is available in the $_SERVER array, see the PHP manual

    If you also need the query string (the bit after the ? in a URL), that part is in this variable:

    $_SERVER['QUERY_STRING']
    

    Use GET to get the value of id . You don't need to use $_SERVER['PHP_SELF'].

    $id  = $_GET['id'];
    

    你可以试试这个代码

    function curPageURL() {
         $pageURL = 'http';
             if ($_SERVER["HTTPS"] == "on") {
                 $pageURL .= "s";
                }
               $pageURL .= "://";
                if ($_SERVER["SERVER_PORT"] != "80") {
                    $pageURL .= $_SERVER["SERVER_NAME"] . ":" .              $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
            } else {
             $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
              }
            return $pageURL;
            }
    
    链接地址: http://www.djcxy.com/p/42292.html

    上一篇: 我无法获得完整的网址路径

    下一篇: 如何在PHP中获取当前浏览器URL?