PHP coding standards (23)_PHP tutorial

WBOY
Release: 2016-07-13 17:20:24
Original
797 people have browsed it

9.1 Constants

Numeric constants located in for loops as counter values, except -1, 0 and 1, should not be written directly into the code.

9.2 Variable assignment

Avoid assigning the same value to multiple variables in one statement. It's hard to read. For example:
$fooBar.fChar = $barFoo.lchar = c; // Error

Do not use the assignment operator in a place where it is easily confused with the equality operator. For example:
if ($c++ = $d++) { // Error
...
}

should be written as
if (($c++ = $d++) != 0 ) {
 ...
}

Do not use embedded assignment operators to try to improve runtime efficiency. This is the job of the compiler. For example:
$d = ($a = $b + $c) + $r; // The error

should be written as
$a = $b + $c;
$d = $a + $r;


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532581.htmlTechArticle9.1 The constant is located in the for loop as a numeric constant of the counter value. Except for -1, 0 and 1, there is no should be written directly into code. 9.2 Variable assignment Avoid assigning the same value to multiple variables in one statement...
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