如何在 PHP 脚本中插入 Google Adsense 代码?

El *_*oub 5 php adsense

如何使用 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;
Run Code Online (Sandbox Code Playgroud)

我只想用 PHP 在 div 中插入 adsense 代码。我还尝试使用 htmlentities 和 stripslashes,但没有显示广告。

I w*_*ce. 3

data-ad-client=<?php echo $client ?>

您已经在 php 解析器中,不需要再次打开它

data-ad-client=$client

修复你也这样做的另一个地方


$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;
Run Code Online (Sandbox Code Playgroud)