• 判断内容页正文是否包含图片,若无图片则显示广告:
    <?php
    $string = $navinfor['newstext']; // 内容字段
    $some = "<img ";
    $num = explode($some, $string);
    if(count($num) > 1) { // 判断内容中是否有图片
    ?>
        [!--newstext--]
    <?php
    } else {
    ?>
        <div id="ad">这里放你的广告代码</div>
        [!--newstext--]
    <?php
    }
    ?>
  • 默认将广告放在内容前,可根据需要调整位置。