Created
August 18, 2016 19:05
-
-
Save alejandrofloresm/9fc4886cc6ee554ba373c5e9b9b601fd to your computer and use it in GitHub Desktop.
Get the url path of the current file
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
<?php | |
function get_this_location_path() { | |
$parts = parse_url($_SERVER['PHP_SELF']); | |
if (!isset($parts['scheme'])) { | |
$parts['scheme'] = "http"; | |
if (isset($_SERVER["HTTPS"]) && | |
$_SERVER["HTTPS"] == "on") | |
{ | |
$parts['scheme'] .= "s"; | |
} | |
} | |
if (!isset($parts['host'])) { | |
$parts['host'] = $_SERVER["SERVER_NAME"]; | |
} | |
$url = $parts['scheme'] . '://' . $parts['host'] . $parts['path']; | |
$url = substr($url, 0, strrpos( $url, '/')); | |
return $url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment