Answers for "how to get current url path in php"

PHP
11

php get full url

$fullURL = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
Posted by: Guest on October-30-2019
3

php get url with get

$full_url = 'http://'.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
Posted by: Guest on March-26-2021
2

php current page url

$protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http' : 'https';
$host     = $_SERVER['HTTP_HOST'];
$script   = $_SERVER['SCRIPT_NAME'];
$params   = $_SERVER['QUERY_STRING'];
 
$currentUrl = $protocol . '://' . $host . $script . '?' . $params;
 
echo $currentUrl;
Posted by: Guest on December-17-2020

Browse Popular Code Answers by Language