How to get the current full url in php?
Ex. full url: www.topclinique.ma/list-cliniques.php?t=cliniques&s=0&c=Casablanca
You can use
$current_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
Try this:
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https://';
}
else {
$protocol = 'http://';
}
$current_link = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
echo $current_link;