Home > php教程 > php手册 > PHP 编码规范(19)

PHP 编码规范(19)

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 10:20:50
Original
971 people have browsed it

7.2 空格

下列情况应该使用空格:
- 一个紧跟着括号的关键字应该被空格分开,例如:
while ( true ) {
...
}

注意:空格不应该置于方法名与其左括号之间。这将有助于区分关键字和方法调用。
- 空白应该位于参数列表中逗号的后面
- 所有的二元运算符,除了".",应该使用空格将之与操作数分开。一元操作符和操作数之间不因该加空格,比如:负号("-")、自增("++")和自减("--")。例如:
$a += $c + $d;
$a = ( $a + $b ) / ( $c * $d );

while ( $d++ = $s++ ) {
  $n++;
}
printSize( "size is " + $foo + " " );

- for语句中的表达式应该被空格分开,例如:
for (expr1; expr2; expr3)

- 强制转型后应该跟一个空格,例如:
myMethod( (byte) $aNum, (int) $x );
myMethod( (int) ($cp + 5 ), ( (int) ($i + 3)) + 1 );


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template