Heim  >  Artikel  >  Backend-Entwicklung  >  谁能帮我看看这个代码错在哪?

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

WBOY
WBOYOriginal
2016-06-06 20:17:351214Durchsuche

这是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>
<code>        public function test(){
            $data['id']=2;
            $this->assign("data",$data);
            $this->display();
        }</code>
<code><if condition="$data['id']%2 eq 0 ">1
        <else></else> 2
    </if></code>

运行正确的案例

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

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

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:html的window怎么使用?如何让这个窗口默认是关闭的?Nächster Artikel:function使用themeConfig错误提示-主键冲突

In Verbindung stehende Artikel

Mehr sehen