now we will learn how we can print the url with simple code
first you must add this two function to your functions
the function
function selfurl() {
$s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s": "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft($s1,$s2) {
return substr($s1, 0, strpos($s1, $s2));
}
Usage
its very simple just use some thing like this:echo 'The Page Url Is:'.selfurl();
