| function getCurrentPageUrl(){ static $pageURL = ''; if(empty($pageURL)){ $pageURL = 'http'; if(isset($_SERVER['HTTPS']) && $_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; } ?> |
Tutorials, Chrome extensions Code samples JavaScript Angular CSS HTML. Updated regularly. Visit and subscribe to the rss feed.
Showing posts with label get current page url in php. Show all posts
Showing posts with label get current page url in php. Show all posts
Thursday, December 11, 2008
Php - Get current page URL
Several times it becomes necessary to find the url of the current page in php. It is not a very big deal to find it, but for a newbie it may take quite some time. So here is a function to do that. The url is stored in a static variable so that it doesn't have to be generated everytime the function is called.
Subscribe to:
Posts (Atom)