我知道不可能为任何给定的PHP设置样式,但我知道可以设置PHP为您提供的输出HTML的样式。我想知道是否有任何方法供我使用,这将使我能够设置IF ELSE语句的输出样式。
if ($result != false) {
print "Your entry has successfully been entered into the blog.";
}
答案 0 :(得分:3)
只需在打印的字符串中使用HTML即可。什么都不需要。
if ($result != false) {
print "<p class=\"success\">Your <strong>entry</strong> has <a href=\"http://example.com/\">successfully</a> been entered into the blog. <img src=\"smileyface.png\" alt=\"Smiley face\" /></p>";
}
答案 1 :(得分:1)
你是说这个?
if ($result != false) {
print "<span style='color:#ff0000'>Your entry has successfully been entered into the blog.</span>";
}
答案 2 :(得分:1)
我喜欢做的只是为了让生活变得简单,就是在我的页面中切换HTML和PHP。例如,
<?php if ($fooSuccess = true) {?>
<p><span style="color: green;">Success!</span></p>
<?php } else {?>
<p><span style="color: red;">Error!</span></p>
<?php } ?>
答案 3 :(得分:0)
然后你需要打印HTML。
if ($result != false) {
print "<b>Your entry has successfully been entered into the blog.</b>";
}
甚至
if ($result != false) {
print "<div class='Style1'>Your entry has successfully been entered into the blog.</div>";
}