Created
June 26, 2013 08:29
-
-
Save kenee/5865740 to your computer and use it in GitHub Desktop.
php get self
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 selfURL() { | |
$s = empty($_SERVER["HTTPS"]) ? '' | |
: ($_SERVER["HTTPS"] == "on") ? "s" | |
: ""; | |
$protocol = $this->strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; | |
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" | |
: (":".$_SERVER["SERVER_PORT"]); | |
return $protocol."://".$_SERVER['SERVER_NAME'].$port.dirname($_SERVER['REQUEST_URI'])."/"; | |
} | |
function strleft($s1, $s2) { | |
return substr($s1, 0, strpos($s1, $s2)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment