首页 > 解决方案 > 如何在 codigniter 中实现 google adsense

问题描述

<script data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>`<ins class="adsbygoogle"
style="display:inline-block;width:728px;height:90px"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxxx"></ins>

标签: google-ads-api

解决方案


将 google adsense 代码存储在通用视图文件中,并将其加载到所需的视图页面中。

例如,将 adsense 代码保存在 adsense.php 视图文件中,并使用以下代码在所需文件中调用它

<?php $this->load->view('adsense'); ?>

推荐阅读