How to get the Current Page URL in php

In this tutorial I’m going to teach you how to get the Current Page URL (Full URL) in PHP, if you already know about $_SERVER array then it is not a big deal for you, those who does not know about that you can visit this link

Let’s write the code:

Copy paste the above script and run, you will see your current page URL.

But, now http is hard coded in the script! what about https then?. Here is the solution,

Let’s write a function to make it clean and reusable:

So you can easily include this function in your existing script and start working with it. Enjoy the day!

Related Posts

Leave a Reply