This PHP snippet comes handy when post login you have to redirect user to the same page which he was browsing earlier.
Syntax
1
2
3
|
<?php
echo "Currently you are on: ".current_url();
?>
|
1
2
3
4
5
6
|
function current_url()
{
$url = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
$validURL = str_replace("&", "&", $url);
return validURL;
}
|
1
2
3
|
<?php
echo "Currently you are on: ".current_url();
?>
|
Get the current URL. Use it with social widgets that require the web page's URL
<?php function get_current_url($full = true) { if (!$full) return $_SERVER['REQUEST_URI']; return'http'.(isset($_SERVER['HTTPS']) ?'s':'').'://'.$_SERVER['HTTP_HOST'].(($_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443) ?'':':'.$_SERVER['SERVER_PORT']).$_SERVER['REQUEST_URI']; } ?>
Hello Friends! I am Ramana a part time blogger from Hyderabad.