Created
November 29, 2010 06:34
-
-
Save gourneau/719659 to your computer and use it in GitHub Desktop.
Find the full URL that a PHP script is running at , minus the name of the 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
//Find the full url to the site we are at | |
$protocol = $_SERVER['HTTPS'] == 'on' ? 'https' : 'http'; | |
$address = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; | |
$currentFile = $_SERVER["SCRIPT_NAME"]; | |
$parts = Explode('/', $currentFile); | |
$currentFile = $parts[count($parts) - 1]; | |
$site_path = str_replace($currentFile,'',$address); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment