FDS’s Blog

2008年12月17日

PHP(返回值)编码规范

Filed under: PHP — 标签: — FDS @ 15:43

返回值

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

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

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

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

评论暂缺 »

还没有任何评论。

这篇文章上的评论的 RSS feed TrackBack URL

留下评论

Powered by WordPress