PHP:Play with Current Page URL

Here come to my attention to share this tips & trick, Story started when there advertiser want to advertise their ad on specific URL on my site, I got confused on how to make it working. Basically every PHP code I have are global and I need to make ads showing on specific URL only. Thanks to google as my best online teacher I do googling and found some code but there is nothing really works 100%. Finally I do some modification and found out how to do it.

First, we have make PHP function here is the code:

function curPageURL() {
$pageURL = ‘http’;
if ($_SERVER[“HTTPS”] == “on”) {$pageURL .= “s”;}
$pageURL .= “://”;
if ($_SERVER[“SERVER_PORT”] != “80”) {
} else {
return $pageURL;

In case if this code not working try to download the original currpage.txt

Then in your global code you need to specify the URL you want something to shown, Example:

if ($d==curPageURL())
echo “this is the code you want to shown”

More specific you can coding more using else function.

What the benefit to play using this code? In case like adsense I do a little tricky to playing with visitor visions, sometimes I do shown my own ad and sometimes adsense ad, Result is google love it!, people not feel annoyed, my adsense CTR raised UP, YAY! 😛

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.