Skip to content

Instantly share code, notes, and snippets.

@wilon
Last active August 6, 2017 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilon/f6f51c19c0c4e1936c7b8729db82ac40 to your computer and use it in GitHub Desktop.
Save wilon/f6f51c19c0c4e1936c7b8729db82ac40 to your computer and use it in GitHub Desktop.
Get the full URL in PHP.
<?php
function getFullURL()
{
$s = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 's' : '';
$p = strtolower($_SERVER['SERVER_PROTOCOL']);
$protocol = substr($p, 0, strpos($p, '/')) . $s;
$host = $_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_ADDR'];
$uri = $_SERVER['REQUEST_URI'] == '/' ? '' : $_SERVER['REQUEST_URI'];
return urldecode("$protocol://$host$uri");
}
@wilon
Copy link
Author

wilon commented Jun 24, 2017

The nginx iis apache test has been passed.

@wilon
Copy link
Author

wilon commented Aug 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment