如何使这个 if 语句适用于 0、1 和 2 只猫?
当 $cats = 0 或 1 时,它会回显“你只有 2 只猫没关系”
有什么代码建议吗?
<?php
//If you have more then 2 cats it is illegal
//if you have 20 or more cats "you are a freak!"
//If you have 2 cats "It is fine you only have 2 cats".
//If you have 1 cats "It is fine you only have 1 cat".
//If you have 0 cats "You don't have any cats no problem".
$cats = 25;
if ($cats > 2 && $cats < 20){
echo "You have too many cats, it is illegal!";
} elseif ($cats >= 20) {
echo "you are a freak!";
} elseif ($cats = 2) {
echo "It is fine you only have 2 cats";
} elseif ($cats = 1) {
echo "It is fine you only have 1 cat";
} elseif ($cats = 0){
echo "You don't have any cats no problem";
}
?>