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

PHP 编码规范(24)

WBOY
WBOYOriginal
2016-06-13 10:20:591354browse

9.3.1 圆括号

一般而言,在含有多种运算符的表达式中使用圆括号来避免运算符优先级问题,是个好方法。即使运算符的优先级对你而言可能很清楚,但对其他人未必如此。你不能假设别的程序员和你一样清楚运算符的优先级。
if ($a == $b && $c == $d) // 错误
if (($a == $b) && ($c == $d)) // 正确


Statement:
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