Home > Backend Development > PHP Tutorial > PHP coding specifications (22)_PHP tutorial

PHP coding specifications (22)_PHP tutorial

WBOY
Release: 2016-07-13 17:20:22
Original
776 people have browsed it

8.4 Variables

Except for variable names, all instances, including classes and class constants, are in mixed case. The first letter of the first word is lowercase, and the first letter of subsequent words is uppercase. Variable names should not begin with an underscore or dollar sign, although this is syntactically allowed.
Variable names should be short and descriptive. Variable names should be chosen to be easy to remember, that is, to indicate their purpose. Try to avoid single-character variable names unless it is a one-time temporary variable. Temporary variables are usually named i, j, k, m and n, which are generally used for integers; c, d, e, which are generally used for character types.

char $c;
int $i;
float $myWidth;
8 instance variable

The case rules are similar to variable names, except that an underscore is required in front

int $_employeeId;
String $_name;
Customer $_customer;
8.6 Constants

Declarations of class constants and ANSI constants should be in all capital letters, with underscores separating words. (Try to avoid ANSI constants, which can easily cause errors)

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


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532582.htmlTechArticle8.4 Variables In addition to variable names, all instances, including classes and class constants, are in mixed case. The first letter of the first word is lowercase, and the first letter of subsequent words is capitalized. Variables...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template