Last active
August 29, 2015 14:06
-
-
Save lytedev/c224d995a19ef034011a to your computer and use it in GitHub Desktop.
Simple PHP "Get Application Root" Function
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 getSiteRoot() | |
{ | |
$docRoot = str_replace("\\", "/", $_SERVER['DOCUMENT_ROOT']); | |
$fileDir = str_replace("\\", "/", dirname(__FILE__)); | |
$cut = explode($docRoot, $fileDir); | |
if (count($cut) > 1) { | |
return $cut[1]; | |
} | |
return $fileDir; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment