谁能帮我看看这个代码错在哪?

WBOY
Release: 2016-06-06 20:17:35
Original
1251 people have browsed it

这是thinkphp框架下 模板里的if语句

<code><if condition="$v['id']%2 eq 0"><div class="cg">
    <else></else><div class="cg2">
    

                            
                        


                                                                                                                        
                     <h2>回复内容:</h2>
                      
                                                            
<p>这是thinkphp框架下 模板里的if语句</p>
<pre class="brush:php;toolbar:false"><code><if condition="$v['id']%2 eq 0"><div class="cg">
    <else></else><div class="cg2">
    

                            
                        
            <p class="answer fmt" data-id="1020000004470191">
                                    </p>
<p><else></else></p>
                            
            <p class="answer fmt" data-id="1020000004470225">
                                    </p>
<p>缺少<else>,你的代码中有<else></else>!没有<else></else></else></p>
                            
            <p class="answer fmt" data-id="1020000004470242">
                                    
</p>
<p>格式是对的呀,下面这个是官网的代码,你看下<code>$v['id']</code>有没有值</p>
<pre class="brush:php;toolbar:false"><code><if condition="$id lt 5 ">value1
<else></else> value2
</if></code>
Copy after login
<code>        public function test(){
            $data['id']=2;
            $this->assign("data",$data);
            $this->display();
        }</code>
Copy after login
<code><if condition="$data['id']%2 eq 0 ">1
        <else></else> 2
    </if></code>
Copy after login

运行正确的案例

对于tp框架模板语法错误,可以根据错误提示到Runtime/Cache文件夹对应模块下的php文件内找出错误。这个语法应该没问题吧。

建议直接输出$v['id']%2 的值先看看。既然没报错。那就不是语法的错误。

你要实现的是偶数项变色或者其他样式吧 根本不用这样处理 css3有一个选择器可以做到

Related labels:
php
source:php.cn
Previous article:html的window怎么使用?如何让这个窗口默认是关闭的? Next article:function使用themeConfig错误提示-主键冲突
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Latest Issues
Related Topics
More>
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template