Get the url of current page using PHP

It often appears that you need to get the current page url in some kind of CMS or on PHP. The code below lists the details of how easy it is to get the full URL.

	if((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') || $_SERVER['SERVER_PORT'] == 443) #Get the site protocol.

	$domain=$_SERVER['SERVER_NAME']; #Get current domain.

	$currentUrl=$_SERVER['REQUEST_URI']; #Get current page link with parameters.

	#As a result, we get the code that gives us the current page url.
	#And separately you can get the parameters passed to the page separately.


If you have any questions, want to get individual advice or you have an interesting offer, you can contact via the feedback form.

Or write to the email

By submitting the form, you agree to our privacy policy