Symfony coding standards(Symfony 代码规范)
-
In the code examples given in this book, you probably noticed that the opening and closing curly braces (
{and}) occupy one line each. This standard makes the code easier to read.{ 和 } 各占一行, 这样的好处是是代码更易于阅读。
-
Among
the other coding standards of the framework, indentation is always done
by two blank spaces; tabs are not used. This is because tabs have a
different space value according to the text editor you use, and because
code with mixed tab and blank indentation is impossible to read.使用两个空格来缩进,不要使用tabs。
-
Core and generated symfony PHP files do not end with the usual
?>closing tag. This is because it is not really needed, and because it
can create problems in the output if you ever have blanks after this
tag.不要在php文件结尾的地方使用
?>,因为一,他不是必要的。二,如果你不小心在其后面输入了空白字符,系统会报错。 -
And if you really pay attention, you will see that a
line never ends with a blank space in symfony. The reason, this time,
is more prosaic: lines ending with blanks look ugly in Fabien’s text
editor.每行最后不要有空格,因为那样在Fabien(Symfony 的作者)的文本编辑器中看起来很丑