在php代码中使用adsense代码



在php标签中使用adsense代码合法吗?这会影响广告的行为吗?

<?php function myfn(){
php code here ?>
 <script  async='async' src="http://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
     <ins class="adsbygoogle"
     style="display:inline-block;width:336px;height:280px"
     data-ad-client="<?php echo $ad_client; ?>"
     data-ad-slot="<?php echo $ad_slot; ?>"></ins>
     <script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
 <?php }?>

并在我想要广告的任何地方调用此函数。

Adsense/Google不在乎你的PHP代码中发生了什么,也不在乎广告块代码在页面的HTML代码中的具体位置,所以只要这个函数有效,并且你没有违反任何其他Adsense规则,比如适当的内容和每页不超过三个广告块,你就应该没事。

如果我可以的话,我的建议是使用响应式广告单元,这样你就可以使用你的广告块/功能,而不用担心容器的大小。https://support.google.com/adsense/answer/3213689?hl=en

最新更新