Search Blog Posts

Returning the Current Page URL

Using PHP you can return the current url of the page by simply using :

$pageURL = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
echo $pageURL;

By using string manipulation you can also us this function to return the end characters of the url request.

For the following url: http://minimalistics.co.uk/gallery/main.php?g2_itemId=89 we can return the end numbers using the following code:
$pageURL = 'http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
$pageURL = substr($pageURL,strrpos($pageURL,"=")+1);
echo $pageURL;

The result of this would be 89.

Tags: , , ,

Post this story to Delicious Post this story to Digg Post this story to Technorati Post this story to SumbleUpon Post this story to Facebook Post this story to Reedit

Leave a Comment

  1. XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

© Copyright 2003-2008 Minimalistic Designs | Terms | Links | Sitemap
Website Design Liskeard - www.minimalistics.co.uk