PHPWeb Development

How to get current page URL in php

Our Current url is

echo $url;

Output :
[mks_highlight color=”#efefef”]/how-to-get-current-page-url-in-php/[/mks_highlight]
REQUEST_URI  return only  root website folder instead of returning full page.
if you want actual link then use this syntax

$actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
echo $actual_link ;

Output :
[mks_highlight color=”#efefef”][/mks_highlight]
In the above code $_SERVER[‘HTTP_HOST’] return the  domain name through which the current request is being fulfilled.

Recommended Tutorials for you


Anuj kumar

This is Anuj Kumar. I’m a professional web developer with 5+ years of experience. I write blogs in my free time. I love to learn new technologies and share with others. I founded PHPGurukul in September 2015. The main aim of this website to provide PHP, Jquery, MySQL, PHP Oops and other web development tutorials. .


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top button