An elegant way is building an array on the fly and using in_array()
:
if (in_array($var, array("abc", "def", "ghi")))
The switch
statement is also an alternative:
switch ($var) {
case "abc":
case "def":
case "hij":
echo "yes";
break;
default:
echo "no";
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…