PHP

PHP code to get the url of a webpage



Instructions: Paste this script in your PHP document where you wish the url of the page to occur 

<?php 
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)); 
} 
?>

Share

Thanks for reading my blog. If you like what I write, why not subscribe to my feed?

If you are busy, I can send the latest post to your email. Just subscribe to my email updates.

 

Enter your email address:

Delivered by FeedBurner

Discussion

No comments for “PHP code to get the url of a webpage”

Post a comment