![](https://img.haomeiwen.com/i4341992/58501683c4666fd7.png)
![](https://img.haomeiwen.com/i4341992/0534d24e328a235b.png)
![](https://img.haomeiwen.com/i4341992/fb7918edbc35e785.png)
如果在index.php中的
return $this->view->fetch('',['user'=>$user]);
改为:
return $this->view->fetch('',['user'=>$user,'age'=>18]);
然后:
![](https://img.haomeiwen.com/i4341992/6f9c41d3d523834c.png)
结果正常!
还可以写成这样:
![](https://img.haomeiwen.com/i4341992/50015f24da8d25c2.png)
总结:比较标签适合于在模板中进行简单的逻辑判断,复杂的推荐使用if等判断语句进行。但无论如何,都不推荐在模板过多使用这类标签,建议尽可能放在控制器进行,使模板专注于数据展示~~
如果在index.php中的
return $this->view->fetch('',['user'=>$user]);
改为:
return $this->view->fetch('',['user'=>$user,'age'=>18]);
然后:
结果正常!
还可以写成这样:
总结:比较标签适合于在模板中进行简单的逻辑判断,复杂的推荐使用if等判断语句进行。但无论如何,都不推荐在模板过多使用这类标签,建议尽可能放在控制器进行,使模板专注于数据展示~~
本文标题:TP5的比较标签
本文链接:https://www.haomeiwen.com/subject/wprloxtx.html
网友评论