PHP Determining the current url

前端 未结 5 1016
悲哀的现实
悲哀的现实 2021-01-13 15:15

I need to modify my function to return also the current folder I am in. Here is my current function:

function getLinkFromHost($url){  
    $port = $_SERVER[\         


        
5条回答
  •  半阙折子戏
    2021-01-13 15:56

    Here's a method that might help:

    function current_url()
    {
        $result = "http";
    
        if($_SERVER["HTTPS"] == "on") $result .= "s";
    
        $result .= "://".$_SERVER["SERVER_NAME"];
    
        if($_SERVER["SERVER_PORT"] != "80") $result .= ":".$_SERVER["SERVER_PORT"];
    
        $result .= $_SERVER["REQUEST_URI"];
    
        return $result;
    }
    

提交回复
热议问题