Skip to content

Instantly share code, notes, and snippets.

@mpmont
Created September 28, 2012 10:01
Show Gist options
  • Select an option

  • Save mpmont/3798967 to your computer and use it in GitHub Desktop.

Select an option

Save mpmont/3798967 to your computer and use it in GitHub Desktop.
always save the query string at the end of file
/**
* Return the entire current url including querystring
*
* @author Jeroen v.d. Gulik
*/
function full_url()
{
return current_url() . get_querystring();
}
/**
* Tries to determine if there is a querystring and returns it
*
* @author Jeroen v.d. Gulik
* @return string
*/
function get_querystring()
{
// Do we have access to QUERY_STRING?
if (!empty($_SERVER['QUERY_STRING']))
{
$qs = $_SERVER['QUERY_STRING'];
}
// Do we have access to REDIRECT_QUERY_STRING?
elseif (!empty($_SERVER['REDIRECT_QUERY_STRING']))
{
$qs = $_SERVER['REDIRECT_QUERY_STRING'];
}
if (isset($qs))
{
$qs = '?' . htmlentities(urlencode($qs));
}
else
// we give up
{
$qs = '';
}
return $qs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment