如何使用PHP回复AdSense代码?这是我为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;
我只想用PHP在div中插入adsense代码.我也试过htmlentities和striplashes但广告没有显示.
解决方法:
data-ad-client =<?php echo $client?>
你已经在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=\"$client\"
data-ad-slot=\"$slot\"
data-ad-format=\"auto\"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</center>
</div>";
echo $adsence;