Simpler way to check if variable is not equal to multiple string values?

前端 未结 7 1265
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-04 19:11

Current Codes:



        
7条回答
  •  庸人自扰
    2020-12-04 19:48

    You may find it more readable to reverse your logic and use an else statement with an empty if.

    if($some_variable === 'uk' || $another_variable === 'in'){}
    
    else {
        // This occurs when neither of the above are true
    }
    

提交回复
热议问题