这似乎是一个很简单的问题,我在这里使用“0888”作为我的输入值示例。我研究了一段时间并尝试了不同的方法,例如
(int) "0888";
intval("0888");
floatval("0888");
settype("0888", "integer");
$num = $_POST['postcode'];
if((1000 <= $num && $num <= 1999) || (2000 <= $num && $num <= 2599) || (2619 <= $num && $num <= 2898) || (2921 <= $num && $num <= 2999)){
$state = "NSW";
}
elseif((0200 <= $num && $num <= 0299) || (2600 <= $num && $num <= 2618) || (2900 <= $num && $num <= 2920)){
$state = "ACT";
}
elseif((3000 <= $num && $num <= 3999) || (8000 <= $num && $num <= 8999)){
$state = "VIC";
}
elseif((4000 <= $num && $num <= 4999) || (9000 <= $num && $num <= 9999)){
$state = "QLD";
}
elseif((5000 <= $num && $num <= 5799) || (5800 <= $num && $num <= 5999)){
$state = "SA";
}
elseif((6000 <= $num && $num <= 6797) || (6800 <= $num && $num <= 6999)){
$state = "WA";
}
elseif((7000 <= $num && $num <= 7799) || (7800 <= $num && $num <= 7999)){
$state = "TAS";
}
elseif((0800 <= $num && $num <= 0899) || (0900 <= $num && $num <= 0999)){
$state = "NT";
}
else {
$state = "Can not find this postcode record";
}
如果我echo $state
希望看到 NT 但实际上我看到的是“找不到此邮政编码记录”。谁能告诉我问题是什么?