Posted: 31st December 2008 by lechu in Hacks, Open Source, Wordpress
Tags: , , ,

A simple function that I had used in the Translation Plugin, this could be your use. This is a PHP function which can get you the URL of the page being visited.

 

function kish_trans_curPageURL() {
    $pageURL = 'http';
     if ($_SERVER["HTTPS"] == "on") {
        $pageURL .= "s";
    }
     $pageURL .= "://";
     if ($_SERVER["SERVER_PORT"] != "80") {
          $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
     } 
    else {
          $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
     }
 return $pageURL;
}

You can print the URL by using this function

Related posts:

  1. Kish Translate WordPress Translation Plugin– Concept
  2. Getting International readers to your blog
  3. WordPress Plugin for Translation
  4. Advantages of adding translation pages for your blog
  5. Modifying Image size for the home page – WordPress
  1. [...] How to get the current URL of web page in PHP (Note: I’ve changed the name of the function from kish_trans_curPageURL to pageURL to keep [...]