Created
January 19, 2019 15:54
-
-
Save CarlasHub/40f6da0d38e510d47e28ddca214aa349 to your computer and use it in GitHub Desktop.
php get url
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function url() | |
{ | |
if (isset($_SERVER['HTTPS']) && | |
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || | |
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && | |
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { | |
$protocol = 'https://'; | |
} else { | |
$protocol = 'http://'; | |
} | |
return $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; | |
} | |
echo url(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment