PHP IF/ELSE 高级语法
三元条件符号
对于简单的IF。。。ELSE。。。语句,PHP提供了一种简单的书写格式 --- 使用三元条件符号 “?:”,与赋值语句联合使用,将使程序更加简明.
例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <?php $result = ($t==0) ? 0 : $y / $t ; echo $result; ?> //即同等于: <?php if($t==0){ $result=0; } else{ $result = $t / $y; echo $result; } ?> |
简单地说,三元条件表达式"expression ? result1 : result2 "中,"?" 的前面是条件表达式,后面是结果.如果表达式 expression 的值为 TRUE ,则返回 result1,否则返回result2.
| -欢迎为本文评级 |
No donations within the last 180 days.Who make donation will leave message at here.Donate Now.
This a wordpress plugin Wp-Donators.It provides a smart donation function to autoleave the sponsor information in this container after payment. People can donate and submit name/URL or TextLink AD. The information of the latest donors are displayed in the cloud. The more a person donates, the bigger their link will be.It's will support most popular payment interface in future. ParPal Just the first one. More..
Powered By:WP-DONATORS
相关日志 |
本文读者也关心以下内容:
|















































Leave a reply