Created
February 5, 2018 23:24
-
-
Save ErlendEllingsen/3b82af9eb7147f5159ba8e1086c6ef93 to your computer and use it in GitHub Desktop.
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 | |
class BasePathGenerator { | |
private static $isSet = false; | |
private static $foundBasePath = null; | |
public static function get() { | |
if (self::$isSet) return self::$foundBasePath; | |
if (!isset($_SERVER['REQUEST_URI'])) return false; | |
$jumps = explode('/', $_SERVER['REQUEST_URI']); | |
$c = count($jumps); | |
$c--; //Remove first element | |
$path = ''; | |
for ($i = 0; $i < $c; $i++) { | |
$path .= '../'; | |
} | |
self::$isSet = true; | |
self::$foundBasePath = $path; | |
return $path; | |
} | |
//end BasePathGenerator | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment