PHP if / else语句 [英] PHP if/else statement
本文介绍了PHP if / else语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是PHP的新手,但发现它非常有用。如何在PHP中编写以下语句:
I'm a complete newbie to PHP but found it can be very useful. How can I write the following statement in PHP:
如果正文ID =home则插入一些html,例如
If body ID = "home" then insert some html, e.g.
<h1>I am home!</h1>
否则,请插入此html:
Otherwise, insert this html:
<p>I'm not home.</p>
谢谢!
推荐答案
使用本机PHP模板执行:
Doing it with native PHP templating:
<?php if ($bodyID==='home') { ?>
<h1>I am home!</h1>
<?php } else { ?>
<p>I'm not home!</p>
<?php } ?>
这篇关于PHP if / else语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文