【发布时间】:2013-03-30 05:38:01
【问题描述】:
我有三个决定结果的变量。只有两个结果,但结果是基于变量的。我想了一些很长的 if 语句,但我想知道是否有更简洁的方法。
$loggedin = (0 or 1) // If it is 0 then one outcome if 1 then it falls onto the next three variables
$status = (0-5) // 4 dead ends
$access = (0-3) //
$permission = (0-9)
最后两个变量的不同组合会导致不同的结果,尽管有些组合是不相关的,因为它们是死胡同。
if ($loggedin == 1 && ($status == 1 || $status == 2 ) && 'whattodohere' ):
我可以手动输入所有组合($access == 0 && ($var == 2 || $var = 6)),但我想知道是否有更好的方法来做到这一点,我不知道。
【问题讨论】:
标签: php if-statement logical-operators comparison-operators