PHP Function current url


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



Copy this code and paste it in your HTML
  1. function curPageURL() {
  2. $pageURL = 'http';
  3. if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
  4. $pageURL .= "://";
  5. if ($_SERVER["SERVER_PORT"] != "80") {
  6. $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
  7. } else {
  8. $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
  9. }
  10. return $pageURL;
  11. }
  12. echo curPageURL();

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.