【发布时间】:2017-07-20 15:54:42
【问题描述】:
我必须开发一个符合一定逻辑的代码
这里
count( $replies ) - 计算页面上的总回复数
$replynumber - 是 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 等的每个回复,基于回复的总数帖子中的用户
我正在尝试根据回复显示基于 adsense 的自定义广告脚本和其他广告脚本
<?php
if( count( $replies ) <= 3 )
{
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ad-->
<ins class="google"
style="display:inline-block;width:200px;height:90px"
data-ad-client="ca-pub-xxxxx"
data-ad-slot="xxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
}
else if(((count( $replies ) > 3) and (count( $replies ) <= 6)) and ($replynumber == '1','3','5'))
{
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ad2-->
<ins class="google"
style="display:inline-block;width:200px;height:90px"
data-ad-client="ca-pub-xxxxx"
data-ad-slot="xxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
}
else if(((count( $replies ) > 6) and (count( $replies ) <= 12)) and ($replynumber == '1','4','7','10'))
{
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ad3-->
<ins class="google"
style="display:inline-block;width:200px;height:90px"
data-ad-client="ca-pub-xxxxx"
data-ad-slot="xxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script> }
}
else if( count( $replies ) > 12 )
{
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- ad4-->
<ins class="google"
style="display:inline-block;width:200px;height:90px"
data-ad-client="ca-pub-xxxxx"
data-ad-slot="xxxx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
}
?>
但这会导致解析错误 哪位大神可以帮忙看看
【问题讨论】:
-
which 行解析错误,究竟是什么?你没说。
-
您也在将纯 JS 注入 PHP;啊,所以就是这样。
-
即使在脚本 1 中也是如此
-
那么如何实现所需
-
您应该分配/回显
<script>作为指令;还是那是伪代码?我这里的问题不清楚
标签: php if-statement logic