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

PHP coding standards (11)_PHP tutorial

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

5.4 Class declaration

When writing classes, the following formatting rules should be followed:

- There should be no space between the left bracket "(" before the method name and its parameter list
- The left brace "{" is at the end of the declaration statement
- The right brace "}" starts on a new line , aligned with the corresponding declaration statement, unless it is an empty statement, "}" should follow "{"

class Sample extends Object {
 int $ivar1;
 int $ivar2;

function Sample(int $i, int $j) {
ivar$1 = $i;
ivar$2 = $j;
}

function emptyMethod() {}

 ...
}

- Methods are separated by blank lines


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532593.htmlTechArticle5.4 Class declaration When writing a class, the following formatting rules should be followed: - Before the method name and its parameter list There should be no spaces between left brackets "(" - left curly brackets "{" are placed on the same line as the declaration statement...
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