我试图让开关返回真或假,但我似乎在某个地方失败了。我一直在说假话。我完全迷路了。这实际上应该有效。我怎样才能做到这一点?
if (validNum(1))
{echo 'Ok';}else{echo 'Fail';}
function validNum($x)
{
switch ($x)
{
case 1:
echo "Number 1";
break;
return true;
case 2:
echo "Number 2";
break;
return true;
case 3:
echo "Number 3";
break;
return true;
default:
echo "No number between 1 and 3";
return false;
}
}