脚本宝典收集整理的这篇文章主要介绍了php – 如果在连接中间声明?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
$given_id = 1; while ($row = MysqL_fetch_array($sql)) { if ($i < 10){ $display = '<a href="' . $row['info'] . '" onMouSEOver="' . if($row['tyPE']=="baTTLe"){ . 'showB' . } else { . 'showA'() . "><div class="' . $row['type'] . "_alert" . '" style="float:left; margin-left:-22px;" id="' . $given_id . '"></div></a>';
(condITional exPression)?(ouput if true):(output if false);
这也可以用于字符串的连接.示例:
$i = 1 ; $result = 'The given number is'.($i > 1 ? 'greater than one': 'less than one').'. So this is how we cuse ternary inside concatenation of strings';
您也可以使用嵌套的三元运算符:
$i = 0 ; $j = 1 ; $k = 2 ; $result = 'Greater One is'. $i > $j ? ( $i > $k ? 'i' : 'k' ) : ( $j > $k ? 'j' :'k' ).'.';
以上是脚本宝典为你收集整理的php – 如果在连接中间声明?全部内容,希望文章能够帮你解决php – 如果在连接中间声明?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。