Skip to content

Instantly share code, notes, and snippets.

@CarlasHub
Created January 19, 2019 15:54
Show Gist options
  • Save CarlasHub/40f6da0d38e510d47e28ddca214aa349 to your computer and use it in GitHub Desktop.
Save CarlasHub/40f6da0d38e510d47e28ddca214aa349 to your computer and use it in GitHub Desktop.
php get url
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