Get the full URL in PHP

Today, We want to share with you Get the full URL in PHP.In this post we will show you php get full url with parameters, hear for php get current url with query string we will give you demo and example for implement.In this post, we will learn about php get current url without query string with an example.

Get the full URL

There are the Following The simple About Fetch the full URL Full Information With Example and source code.

As I will cover this Post with live Working example to develop php get current url path, so the php get full url with hash for this example is following below.

$actual_link = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";

both HTTP and HTTPS, you can use

$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";

<h3>GET current page full URL in php</h3>
echo $url;

How to get URL of current page in PHP



<?php echo $_SERVER['REQUEST_URI']; ?>

Get current URL path in PHP


 $relative_path = $_SERVER['PHP_SELF'];
 $complete_path = __FILE__;
 $complete_path = $_SERVER['REQUEST_URI'];

PHP $_SERVER Superglobal Variable

How to get current page URL in PHP

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

PHP: How to Get the Current Page URL

function curPageURL() {
 $liveURI = 'http';
 if ($_SERVER["HTTPS"] == "on") {$liveURI .= "s";}
 $liveURI .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 } else {
 return $liveURI;

  echo curPageURL();

function curPageName() {
 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);

echo "The current page name is ".curPageName();

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple Fetch full URL Server Side.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1.   PHP Get domain name from full URL with parameters
  2.   Laravel 6 Advanced Where Clauses Tutorial With Example
  3.   Convert JSON to CSV using PHP Example
  4.   vuejs onchange Event - vuejs v-on change Examples
  5.   Multiple Image Upload using PHP into MYSQL database
  6.   PHP Get Current URL Full Path HTTP-HTTPS Protocol
  7.   Laravel 5.8 Image Resize Tutorials
  8.   How to get the current page name using PHP?
  9.   call to undefined function str_slug()
  10.   Laravel Get HTTP hostname with Example