我正在创建一个响应式模板,为此我需要使用if if else和function。这是我到目前为止所做的。
<?php if ($this->countModules('left')) { ?>
<p>Left + Content</p>
<?php } elseif ($this->countModules('right')) { ?>
<p>Right + Content</p>
<?php } elseif ($this->countModules('left')) && ($this->countModules('right')) { ?>
<p>Left + Right + Content</p>
<?php } else { ?>
<p>Content</p>
<?php } ?>
我现在收到错误: 解析错误:语法错误,意外'&amp;&amp;'第197行的index.php中的(T_BOOLEAN_AND)
第197行=
<?php } elseif ($this->countModules('left')) && ($this->countModules('right')) { ?>
我尝试添加额外的()但是没有用:
<?php } elseif (($this->countModules('left')) && ($this->countModules('right'))) { ?>
我忘了什么,但是什么。
答案 0 :(得分:0)
您的括号位于错误的位置。请尝试替换以下内容:
<?php } elseif ($this->countModules('left')) && ($this->countModules('right')) { ?>
用这个:
<?php } elseif ($this->countModules('left') && $this->countModules('right')) { ?>
答案 1 :(得分:0)
顺序错误,而不是添加(),你应该删除一个集合。请参阅下面的改编代码。
<?php if ($this->countModules('left') && $this->countModules('right')) { ?>
<p>Left + Right + Content</p>
<?php } elseif ($this->countModules('right')) { ?>
<p>Right + Content</p>
<?php } elseif ($this->countModules('left')) { ?>
<p>Left + Content</p>
<?php } else { ?>
<p>Content</p>
<?php } ?>
希望这会让你走上正确的道路。