这是我的代码:
$oldPhone = $_POST["phone"];
$newPhone = makeInteger($oldPhone);
lengthMustBe($newPhone, 10, "Please enter a valid 10-digit phone number.");
这是功能:
function lengthMustBe($str, $length, $errormsg) {
if (strlen($str) != $length) {
$status = "failure";
$error = $errormsg;
}
};
该功能非常不言自明..
当我尝试通过它时"123", 10, "Not long enough"
, $status 仍然是“成功”(在页面顶部定义。)