Absolute URL function


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // This function defines the Absolute URL
  2.  
  3. function absolute_url($page = 'index.php') {
  4.  
  5. $siteURL = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
  6.  
  7. // Remove trailing slashes
  8.  
  9. $siteURL = rtrim($siteURL, '/\\');
  10.  
  11. // Add the page...
  12.  
  13. $siteURL .= '/' . $page;
  14.  
  15. // return the url..
  16.  
  17. return $siteURL;
  18.  
  19. } // End function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.