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

PHP 编码规范(11)

WBOY
Release: 2016-06-13 10:20:36
Original
773 people have browsed it

5.4 类的声明

当编写类时,应该遵守以下格式规则:

- 在方法名与其参数列表之前的左括号"("间不要有空格
- 左大括号"{"位于声明语句同行的末尾
- 右大括号"}"另起一行,与相应的声明语句对齐,除非是一个空语句,"}"应紧跟在"{"之后

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

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

function emptyMethod() {}

  ...
}

- 方法与方法之间以空行分隔


source:php.cn
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template