任何想法爲什麼這不會打印錯誤?數組和foreach
// Validate the email
if (preg_match($regex, $email))
$errors[] = "Invalid email address";
// ... and the password
if (strlen($password) < 4)
$errors[] = "Password is too short";
// No errors?
if (empty($errors))
{
// insert into db
}
// If there were any errors, show them
if (!empty($errors))
{
$errors = array();
foreach ($errors as $error)
echo '<li>'.$error.'</li>';
}
能否請您與您的縮進少粗心?它會讓任何代碼維護者可能會恨你。我知道我正在冒... – brianreavis