You can use the $_SERVER built-in variable to get the current page URL in PHP. The $_SERVER is a superglobal variable, which means it is always available in all scopes.
Also if you want full URL of the page you'll need to check the scheme name (or protocol), whether it is http or https. Let's take a look at an example to understand how it works:
Use the PHP
$_SERVERSuperglobal VariableYou can use the
$_SERVERbuilt-in variable to get the current page URL in PHP. The$_SERVERis a superglobal variable, which means it is always available in all scopes.Also if you want full URL of the page you'll need to check the scheme name (or protocol), whether it is
need an explanation for this answer? contact us directly to get an explanation for this answerhttporhttps. Let's take a look at an example to understand how it works: