Assign Google Adsense Code to a PHP Variable

Assigning Google Adsense code to a PHP variable doesn’t work the way you would expect it to. I thought just deleting the newline characters and extra spaces from the adsense code and then assigning the resulting text to a variable should work. However it does not, and I’m not sure why. However what does work is shown below.

<?php
$googleadsensecode = '
<script type="text/javascript">
google_ad_client = "pub-123456789";
google_ad_slot = "123456";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>';
echo $googleadsensecode;
?>

The following example does not work.

<?php
$googleadsensecode = '<script type="text/javascript"> <!-- google_ad_client = "ca-pub-123456789"; google_ad_slot = "123456"; google_ad_width = 300; google_ad_height = 250; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>';
echo $googleadsensecode
?>

Adsense Client – Simple Adsense Application for your Android Phone

Introducing “Adsense Client” – a new Android application I have created to help you track your Adsense Earnings on the go. I have been look for a decent application to track my Adsense Earnings. However all the free applications are severely limited and do not offer even the basic functionalities and hence I decided to make one of my own. This is my first attempt at making a full fledged Android application. I have tested this application across all Android software versions greater than 1.5. This application won’t work for Android s/w versions less than 1.5. Continue reading