更多的是一个风格问题,但是如何在源代码中将 HTML 选项卡与脚本逻辑选项卡混合使用?这可能不是陈述问题的最佳方式,但我认为一个简单的例子可以很好地证明这一点。注意标签:
<table>
<tr><td>This is the first row</td></tr>
<? if ($test == true) { ?>
<tr><td>Only display the second row if some test is true</td></tr>
<? } ?>
</table>
对比
<table>
<tr><td>This is the first row</td></tr>
<? if ($test == true) { ?>
<tr><td>Only display the second row if some test is true</td></tr>
<? } ?>
</table>
我知道在 PHP 中你可以巧妙地使用 if 语法并执行“if(something):”然后执行“endif;” 之后。但这相当于同一件事。
你的代码标签应该基于 HTML 还是基于逻辑条件。我问这个是因为我正在开发一个没有 MVC 的项目(不是 PHP,而是类似的脚本语言),因此 HTML 中混合了大量逻辑,并且在选项卡方面可能会变得非常混乱。如果您基于这两个代码进行选项卡,那么您的代码最终会离左边距太远。这里有什么标准可以遵循吗?