Get Current Page URL PHP

There is a few methods of getting this but here is a simple one. Replacing the http or https manually. 

$current_url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

Here is a more complex version of this that can check if there is http or https in the current url.

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

Other Items in php
Page Views

This page has been viewed 246 times.

Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.

❤👩‍💻🕹

Random Quote
The happiest People don't have the best of everything, they just make the best of everything.
Unknown