Last active
August 6, 2017 14:22
-
-
Save wilon/f6f51c19c0c4e1936c7b8729db82ac40 to your computer and use it in GitHub Desktop.
Get the full URL in PHP.
This file contains hidden or 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
<?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"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The
nginx
iis
apache
test has been passed.