這裏是我的代碼:PHP - 我能正確調用一個函數嗎?
$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"
,$地位仍然「成功」(定義在頁面頂部)
刪除;在函數結尾處+您需要定義超出所有代碼的函數 – SolidSnake 2013-05-14 00:07:35
如何檢查'$ status'值? – Tchoupi 2013-05-14 00:07:59