本文介绍了

问题描述

我一直在使用 代码,这些代码无需任何模板即可生成 HTML,而且按照他们的结构方式很难阅读.我注意到的一种大幅改进流程的方法是在某些情况下使用 : endif 而不是 { } 块以提高可读性.(参见

干杯!

是的

这是标准吗?

是的

这是否会以任何显着的方式变慢(我知道它需要更多字符)

我不知道.

但是恕我直言,如果您将其与 HTML 结合使用,它会极大地提高可读性和可维护性.

示例:

<?

对比

<?

这只是一个小例子,但我认为 endifendforeach 更容易识别为 <?.所以是的,一定要在 HTML 中使用它!

我不会在其他任何地方使用它,因为在普通"代码中我发现它更难阅读.

I've been working with code that generates HTML without any templating, and it's quite spaghetti and difficult to read with the way they've structured it. One way to drastically improve following the flow I've noticed is to use : endif instead of { } blocks in some cases to increase readability. (See

Cheers!

Yes

Yes

I don't know.

But imho it increases readability and maintainability very much if you use it in combination with HTML.

Example:

<?

vs

<?

It is just a small example but I think endif and endforeach are much easier to spot as <?. So yes, definitely use it with HTML!

I don't use it anywhere else though because in "normal" code I find it more difficult to read.

这篇关于