;另一種是PHP套HTML,寫作
<?php echo ?>
,若php開啟短標(biāo)簽寫法,也可寫作
<?=$item['RAND']?>
還有一種不太常用的混合寫法如下:
easy way to execute conditional html / javascript / css / other language code with php if else:
<?php if (condition):?>
html code to run if condition is true
<?php else: ?>
html code to run if condition is false
<?php endif ?>
列出項(xiàng)目中的一段代碼的兩種寫法:
<?php
if($resitem['PREVIEW']){
echo $resitem['PREVIEW'];
} else {
echo "static/images/bg72.png";
}
?>
寫法二:
<?php
if($resitem['PREVIEW']): ?> <?=$resitem['PREVIEW']?><?php else: ?>static/images/bg72.png<?php endif ?>
總結(jié)完畢;感謝大家的閱讀,希望大家有所收益。
更多可以參考官方文檔http://www.php.net/manual/zh/control-structures.if.php
本文轉(zhuǎn)自:https://blog.csdn.net/freshlover/article/details/9279527
推薦教程:《php教程》
更多關(guān)于云服務(wù)器,域名注冊(cè),虛擬主機(jī)的問題,請(qǐng)?jiān)L問西部數(shù)碼官網(wǎng):m.ps-sw.cn