Oct
31
Posted on October 31, 2008 by Dayson Pais (Articles, PHP, WebDev)

When you feel you may want to use the requested url with all the get variables passed (just the way it is in the browser’s address bar), you can use the following code snippet:

private function getCurPageURL()
{
	$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;
}
    Print Version    

No comments yet, your thoughts are welcome?

Post a Comment
Name:
Email:
Website:
Comments: