Home >Backend Development >PHP Tutorial >PHP coding standards (19)_PHP tutorial

PHP coding standards (19)_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:20:16822browse

7.2 Space

Spaces should be used in the following situations:
- A keyword immediately followed by brackets should be separated by spaces, for example:
while ( true ) {
...
}

Note: Spaces should not be placed between the method name and its opening bracket. This will help distinguish keywords from method calls.
- Whitespace should follow the comma in the argument list
- All binary operators, except ".", should be separated from their operands by whitespace. There should be no spaces between unary operators and operands, such as negative sign ("-"), increment ("++") and decrement ("--"). For example:
$a += $c + $d;
$a = ( $a + $b ) / ( $c * $d );

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

- The expression in the for statement should be separated by spaces, for example:
for (expr1; expr2; expr3)

- The cast should be followed by a space, for example :
myMethod( (byte) $aNum, (int) $x );
myMethod( (int) ($cp + 5 ), ( (int) ($i + 3)) + 1 );


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532585.htmlTechArticle7.2 Spaces Spaces should be used in the following situations: - A keyword followed by brackets should be separated by spaces, for example: while ( true ) { ... } Note: Spaces should not be placed between method names and...
Statement:
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