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

PHP 编码规范(26)

WBOY
WBOYOriginal
2016-06-13 10:21:031003browse

9.3.3 返回值

设法让你的程序结构符合目的。例如:
if (booleanExpression) {
  return true;
} else {
  return false;
}

应该代之以如下方法:
return booleanExpression;

类似地:
if (condition) {
  return x;
}
return y;

应该写做:
return (condition ? x : y);


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