<?php ?>
;另一种是php套html,写作
<?php echo ?>
,若php开启短标签写法,也可写作
<?=$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 ?>
列出项目中的一段代码的两种写法:
<?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 ?>
总结完毕;感谢大家的阅读,希望大家有所收益。
更多可以参考官方文档http://www.php.net/manual/zh/control-structures.if.php
本文转自:https://blog.csdn.net/freshlover/article/details/9279527
推荐教程:《php教程》
以上就是详细解说三种php嵌套html的写法的详细内容。
