Answers for "get current URL path php"

PHP
1

Get Current Page URL in PHP

<?php
$uri = $_SERVER['REQUEST_URI'];
echo $uri; // Outputs: URI 

$protocol = ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; 
$url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
echo $url; // Outputs: Full URL 

$query = $_SERVER['QUERY_STRING'];
echo $query; // Outputs: Query String
?>
Posted by: Guest on July-30-2021
3

php get url with get

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

Browse Popular Code Answers by Language