我开始学习一种新的PHP符号,我比标准
更好<?php if (...)
{
// code here
} ?>
相反,它使用
<?php if (...) :
// code here
endif; ?>
但我无法弄清楚如何把别的东西放在那上面。有人可以告诉我该怎么做吗?
答案 0 :(得分:3)
control structures的辅助表示法
<?php if (cond): ?>
<?php elseif(cond): ?>
<?php else: ?>
<?php endif; ?>
在模板化HTML时,您应该只使用这种表示法,因为块和缩进使代码更易读,更容易理解。一些程序员会争辩说,无括号的符号应该从不使用。
答案 1 :(得分:0)
/* Correct Method: */
if($a > $b):
echo $a." is greater than ".$b;
elseif($a == $b): // Note the combination of the words.
echo $a." equals ".$b;
else:
echo $a." is neither greater than or equal to ".$b;
endif;