Guest User

Untitled

a guest
Dec 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. function getBaseUrl() {
  2. // output: /myproject/index.php
  3. $currentPath = $_SERVER['PHP_SELF'];
  4.  
  5. // output: Array ( [dirname] => /myproject [basename] => index.php [extension] => php [filename] => index )
  6. $pathInfo = pathinfo($currentPath);
  7.  
  8. // output: localhost
  9. $hostName = $_SERVER['HTTP_HOST'];
  10.  
  11. // output: http://
  12. $protocol = strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,5))=='https://'?'https://':'http://';
  13.  
  14. // return: http://localhost/myproject/
  15. return $protocol.$hostName.$pathInfo['dirname']."/";
  16. }
  17.  
  18. $base = getBaseUrl();
  19. require_once $base.'_include/db/qry.php';
  20. require_once $base.'_include/db/functions.php';
  21.  
  22. Warning: require_once(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:xampphtdocsmysite_includeheader.php on line 9
  23.  
  24. Warning: require_once(http://localhost/mysite/_include/db/qry.php): failed to open stream: no suitable wrapper could be found in C:xampphtdocsmysite_includeheader.php on line 9
  25.  
  26. Fatal error: require_once(): Failed opening required 'http://localhost/mysite/_include/db/qry.php' (include_path='.;C:xamppphpPEAR') in C:xampphtdocsmysite_includeheader.php on line 9
  27.  
  28. // just example, change to fit your real path.
  29. $base = __DIR__ . '/../';
  30.  
  31. require_once $base.'_include/db/qry.php';
  32. require_once $base.'_include/db/functions.php';
Add Comment
Please, Sign In to add comment