I use the following for getting the current URL in PHP:
$pageURL = $_SERVER["REQUEST_URI"];
return $pageURL;
This is used in my links to create eg /login?continue=/page/i/want
However when I'm viewing the home page I will get /login?continue=
how do I force it to become /login?continue=/
when viewing the home page??
I tried this:
if($pageURL == '')
$pageURL = '/';
but that didn't force the query string :/
Any ideas? Thanks
Try something like this, it will work only if the url has one "=" only:
$url = $_SERVER["REQUEST_URI"];
$arr = explode("=", $url);
if(empty($arr[1])) {
$url .="/";
}
echo $url;
Hope it helps
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.