$_SERVER['REQUEST_URI']
, i.e. $actual_link = "https://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
(Note that the double quoted string syntax is perfectly correct.)
If you want to support both HTTP and HTTPS, you can use
$actual_link = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
⚠️ Using this code has security implications because the client can set HTTP_HOST
and REQUEST_URI
to arbitrary values. It is absolutely necessary to sanitize both values and do meaningful input validation.
How to create an array from a CSV file using PHP
How to pass an array within a query string?
Insert new item in array on any position in PHP
How to check whether an array is empty using PHP?
Converting an integer to a string in PHP
How can I add elements to an empty array in PHP?
How to find the foreach index?
How can I capture the result of var_dump to a string?