Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Determining the current url

Tags:

directory

url

php

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['REMOTE_PORT'];  
    $server = $_SERVER['HTTP_HOST'];  
    if($port == 443){  
        $type = "https";  
    } else {  
        $type = "http";  
    }  
    return $type . "://" . $server . "/" . $url;  
}
like image 973
somejkuser Avatar asked Dec 05 '22 04:12

somejkuser


1 Answers

Take a look at $_SERVER['REQUEST_URI'] or $_SERVER['SCRIPT_NAME']

(From the $_SERVER manual entry)

like image 108
Mark Biek Avatar answered Dec 18 '22 02:12

Mark Biek