Home >Backend Development >PHP Tutorial >PHP coding standards (11)_PHP tutorial
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