【发布时间】:2015-06-22 16:54:19
【问题描述】:
我是 PHP 新手,正在为 Joomla K2 项目布局编写模板文件。
我配置了一个“额外字段”$extrafields[15],其输出为“是”、“否”或“”。 $extrafields[16] 是一个文本字符串。
我有这段代码,它可以工作,但会就如何简化它提出建议,因为我知道它可能有点粗糙!
if (!empty($extrafields[15])):
if ($extrafields[15] == "Yes") {
echo "<span class=sgl-bold>Sponsored by: </span>";
}
if ($extrafields[15] == "Yes"):
if (!empty($extrafields[16])):
echo $extrafields[16];
endif;
echo "<br>";
endif;
endif;
【问题讨论】:
-
if (something is true) { if (it's still true) { ... } }是相当多余的......
标签: php joomla coding-style