为什么会有不同的语法相同的结果?为什么会有不同的语法相同的结果?
例如
# Example 1
if($myCondition == true) :
#my code here
endif;
if($myCondition == true) {
#my code here
}
# Example 2
foreach($films as $film) :
#my code here
endforeach;
foreach($films as $film) {
#my code here
}
而且我一直在使用<?=
的年龄了,我现在明白了,已经过时,我应该使用<?php echo
是这样的话,为什么?每次都要写出来更麻烦。
你的想法是什么?
默认情况下,停用的原因是你必须写''多于几次,使用模板引擎。在相同的文件中有HTML和PHP代码是非常肮脏的。 –
ThiefMaster
2010-06-11 11:41:19
@ThiefMaster PHP本身就是一个模板引擎。无论你是编写'{$ smartySucks}'还是'<?php echo $ someVar; ''没关系。只有当你开始将逻辑混合到模板中时它才会变脏。 – Gordon 2010-06-11 12:02:37
@戈登有关你的例子似乎有偏见:p – 2010-06-11 12:11:16