简体   繁体   English

PHP PSR-2之前/之后的新行

[英]PHP PSR-2 new lines before/ after statments

Example no 1: 示例1:

$something = [1,2,3,4]
foreach ($something as $key => $value) {
    //code code code
}
$something2 = [];

I can't find clear answer about new live before and after foreach, what PSR-2 say about that ? 关于foreach之前和之后的新生活,我找不到明确的答案,PSR-2对此有何评论?

Point 2.3 "Lines" Make it optional to add blank lines before and after statements. 点2.3“行”使语句在语句前后添加空行是可选的。 It is still useful to separate code blocks in "paragraphs" to improve logic comprehension and readability. 在“段落”中分隔代码块以提高逻辑理解和可读性仍然很有用。

Blank lines MAY be added to improve readability and to indicate related blocks of code. 可以添加空行以提高可读性并指示相关的代码块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM