还有一种不太常用的混合写法如下:
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] view plaincopy
<?php if($resitem['PREVIEW']){echo $resitem['PREVIEW']} else {echo "static/images/bg72.png"}?>
写法二:
[php] view plaincopy
<?php if($resitem['PREVIEW']): ?><?=$resitem['PREVIEW']?><?php else: ?>static/images/bg72.png<?php endif ?>
<pre t="code" l="php"><html><br /><head><br /><body><br /> <?php<br /> '你的php代码<br />?> <br /></body><br /></html></pre><p>php嵌套html, 这里html是指html语言, 而不是h孩单粉竿莠放疯虱弗僵tml文件!</p><p>html语言和html文件, 是两个概念</p>.