How to echo AdSense code with PHP? Here is the sample of my code which I am working for a codeigniter php.
$adsence = "
<div class=\"right-inner\">
<center width=\"96% class=\"img-responsive center-block\">
<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<!-- quiz_net -->
<ins class=\"adsbygoogle\"
style=\"display:block\"
data-ad-client=<?php echo $client ?>
data-ad-slot=<?php echo $slot ?>
data-ad-format=\"auto\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>
</div>";
echo $adsence;
All I want to insert adsense code inside a div with PHP. I also tried with htmlentities along with stripslashes but ad in not getting displayed.
data-ad-client=<?php echo $client ?>
you're already in the php parser, don't need to open it again
data-ad-client=$client
fix the other spot where u did that too
$adsence = "
<div class=\"right-inner\">
<center width=\"96% class=\"img-responsive center-block\">
<script async src=\"//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js\"></script>
<!-- quiz_net -->
<ins class=\"adsbygoogle\"
style=\"display:block\"
data-ad-client=\"$client\"
data-ad-slot=\"$slot\"
data-ad-format=\"auto\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>
</div>";
echo $adsence;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With