【发布时间】:2012-09-12 19:42:13
【问题描述】:
我无法理解的简写 if 语句有点麻烦
($product == "vindo") ? $this->getNextVindoInList($id) : $this->getNextGandrupInList($id),
这很好用,但我想在该语句中再检查一次。像这样:
if($product == "vindo") {
if($number != 14) {
$this->getNextVindoInList($id)
}
} else {
if($number != 22) {
$this->getNextGandrupInList($id)
}
}
【问题讨论】:
-
小心,使用过多会导致代码难以阅读!!!它的性能提升也很小,既不快也不慢。
-
请不要这样。短代码不是更好的代码。
标签: php if-statement shorthand-if