Hello Friends, As all of us is aware that Google Adsense is best publisher network used across globe and no one can doubt it. Maximum blogger are using Adsense publisher program as main income source by displaying various types of ads and the Bloggers makes money from it as soon as people click on ads. To do this we need to add this Adsense code into the blog and as we know maximum blogs are using wordpress tool which is based on PHP language so ultimately we need o add the code into PHP. But in fact I will say that it is very easy task to add this code to wordpress as there are many plugins are available to do it. But if you are going to create custom website you get into trouble to implement Adsense code as may any kind of problems can arrive.
Put/Add Google Adsense Code in proper way in PHP Script Used Websites?
Whenever we use self hosted websites, the ad units code are expected to get added manually just because it do not accept HTML/JavaScript codes. Instead HTML and Javascripts code can be the perfect solution for blogging sites and other type of websites.In order to add adsense unit code to PHP Script we need to change the original code in some manner to place it in correct way. For wordpress based site which provides CMS need not to worry as they provide various types of plugins to place adsense code into the website. But still issue left for the customize websites let us say PHP coded website.
Following is the solution to your problem, This solution can help you to Add/Insert Google Adsense Code in PHP Script in right way. Let us check it out now,
Insert/Add Google Adsense Code in PHP Script based websites
This is the original Adsense code provided by Google looks like shown below,
<script type=”text/javascript”>
google_ad_client = “PUBLISHER ID”;
google_ad_slot = “4653265601”;
google_ad_width = 350;
google_ad_height = 600;
</script>
<!– AD NAME –><script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>
Now we will change it to our way, To make it usable in PHP code and to get result in HTML form is as follows,
<?php
//assign adsense code to a variable
$googleadsensecode = ‘
<script type=”text/javascript”>
google_ad_client = “PUBLISHER ID”;
google_ad_slot = “4653265601”;
google_ad_width = 350;
google_ad_height = 600;
</script>
<!– AD NAME –><script type=”text/javascript”
src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”>
</script>’;
//now we will get output in HTML form
echo $googleadsensecode;
?>
And that’s it you have added Adsense code successfully to your website and you won’t face any problem. If still any problem arrives then do not forget to share with us, We are waiting for your questions. If you like this article then like it and share this post with your friends! We will come back with good topic again soon, Good day;)
Leave a Reply