Guest User

Untitled

a guest
Feb 18th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2. class BasePathGenerator {
  3. private static $isSet = false;
  4. private static $foundBasePath = null;
  5. public static function get() {
  6. if (self::$isSet) return self::$foundBasePath;
  7. if (!isset($_SERVER['REQUEST_URI'])) return false;
  8. $jumps = explode('/', $_SERVER['REQUEST_URI']);
  9. $c = count($jumps);
  10. $c--; //Remove first element
  11. $path = '';
  12. for ($i = 0; $i < $c; $i++) {
  13. $path .= '../';
  14. }
  15. self::$isSet = true;
  16. self::$foundBasePath = $path;
  17. return $path;
  18. }
  19. //end BasePathGenerator
  20. }
  21. ?>
Add Comment
Please, Sign In to add comment