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

PHP 编码规范(22)

WBOY
Release: 2016-06-13 10:20:56
Original
991 people have browsed it

8.4 变量

除了变量名外,所有实例,包括类,类常量,均采用大小写混合的方式,第一个单词的首字母小写,其后单词的首字母大写。变量名不应以下划线或美元符号开头,尽管这在语法上是允许的。
变量名应简短且富于描述。变量名的选用应该易于记忆,即,能够指出其用途。尽量避免单个字符的变量名,除非是一次性的临时变量。临时变量通常被取名为i,j,k,m和n,它们一般用于整型;c,d,e,它们一般用于字符型。

char $c;
int $i;
float $myWidth;
8 实例变量

大小写规则和变量名相似,除了前面需要一个下划线

int $_employeeId;
String $_name;
Customer $_customer;
8.6 常量

类常量和ANSI常量的声明,应该全部大写,单词间用下划线隔开。(尽量避免ANSI常量,容易引起错误)

static final int $MIN_WIDTH = 4;
static final int $MAX_WIDTH = 999;
static final int $GET_THE_CPU = 1;


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