How to get current page URL in PHP

August 1, 2019

In This Tutorial, We are Learning How to get Current Page URL in PHP.

$_SERVER

$_SERVER is the Superglobal Variable in PHP. $_SERVER is an Array Containing Information such as Headers, Paths and Script Locations. You can get current page URL in PHP.

The example below shows How to get current page URL in PHP

If You want Full Page URL. You have to Check the Protocol, Host and URL. First We Create the $protocol variable to check the value of Protocol. If site have SSL Certificate then $protocol = ‘https’ else $protocol = ‘http’.

Concatenation the All Variable. You can get Complete URL.

For More Detail

Hope this Help

Karan Suthar

Surat, India

I'm Karan, the creator Behind the KTechBlog. I write Blogs in my Free Time. I ❤ to learn new Technologies and Share with Others. I'm Trying best effort to make KTechBlog useful for Everyone.