Category Archives: Finding Current URL in PHP

How to find the Current URL in PHP

For Introduction Click Me
How to find the current Domain in PHP?

If you need the current domain of the site/url .Here is the sample code

<?php
// Using HTTP_HOST

$domain_name = $_SERVER['HTTP_HOST'];
echo $domain_name;
?>

if the current url structure is:http://www.phpfresher.com. Remember http://www. part is excluded. The output will be phpfresher.com
If you need to make the link please concatenate the http://www. part with the output