In Blogger who don't have the same problem because you have the
<$BlogItemPermalinkURL$> tag that returns the post's URL.
Here's the PHP sourcecodes:
function getOwnURL()
{
$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));
}
To use, just invoke the function within the PHP print method like this:
print(getOwnURL());
0 comments:
Post a Comment