比如在wordpress的模板里经常看到这样的语法
<?php if (have_post()): ?><div>...</div><?php endif; ?>
为什么还要像if (...):
和endif;
这样写?这是什么语法?为什么不用括号呢?
解决方案
上下标签对应的逻辑语法约定俗成拿来做原生的模板语言
类似的还有
while(..): endwhile;
foreach(..): ... endforeach;
比如在wordpress的模板里经常看到这样的语法
<?php if (have_post()): ?><div>...</div><?php endif; ?>
为什么还要像if (...):
和endif;
这样写?这是什么语法?为什么不用括号呢?
上下标签对应的逻辑语法约定俗成拿来做原生的模板语言
类似的还有
while(..): endwhile;
foreach(..): ... endforeach;