Posted By

sidisinsane on 12/02/08


Tagged

url php path


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

orionx9
robe
arthipesa
claudiowebdesign


Get the full URL of current document


 / Published in: PHP
 

  1. // Returns the full URL of the current document.
  2. function getCurrentUrl()
  3. {
  4. // Checks scheme.
  5. $url = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
  6. // Checks port.
  7. $url .= ($_SERVER['SERVER_PORT'] != '80') ? $_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$_SERVER['REQUEST_URI'] : $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
  8.  
  9. // Returns full URL.
  10. return $url;
  11. }

Report this snippet  

You need to login to post a comment.