模板输出的数组中增加三元运算符来判断,数组运算符
得出一个好用的判断方法,在模板输出的数组中增加三元运算符来判断,挺方便的。当然你也可以用Ajax~
<span><html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题</title> </head> <body><span> 我的口号是什么?——</span>><{<span>$data</span>['user']?'没有问题':Wow搞大了}> <br/> //提醒:三元运算符不能接受符号,不然会报错! <{<span>$data</span>['email']}> <br/> <{<span>$data</span>['address']}><br/> <{<span>$data</span>['num']+10}><br/> </body> </html></span>
控制器方法
<span><?php</span><br /><span>namespace Home\Controller;</span><br /><span>use Think\Controller;</span><br /><span> <span>public</span> <span>function</span><span> index(){ </span><span>$data</span>['user']='我爱的是你爱我'<span>; </span><span>$data</span>['email']='integer@gmail.cn'<span>; </span><span>$data</span>['address']='中国大陆'<span>; </span><span>$data</span>['num']='21'<span>; </span><span>//</span><span>$this->assign('num',10);</span> <span>$this</span>->assign('data',<span>$data</span><span>); </span><span>$this</span>-><span>display(); }</span></span>
三元运算符 ?:
例如:i= 2 > 3 ? 0 : 1
2大于3嘛,如果是,就得到i = 0;否则i=1.
选B
三目运算符?:; ,属于关系运算符,
常用于关系比较,主要用于比较关系的状态只有两种的情况(大于 和 不大于,真 和 假)
先求表达式1的值, 如果为真, 则执行表达式2,并返回表达式2的结果 ; 如果表达式1的值为假, 则执行表达式3 ,并返回表达式3的结果
比如以下表达式:
a>0? a++:(a = 1)
当a>0为真 时,执行a++,整个表达式的值等于表达式a++的值,
当a>0为假 时,执行a=1,整个表达式的值等于表达式a=1的值。
参考资料:zhidao.baidu.com/question/341063017.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Atom editor mac version download
The most popular open source editor
