if 语句 - PHP 中的简单比较不起作用


if statement - simple comparison in PHP not working

这是我的函数:

function checkForDuplicates($items, $checkitem)
{
    $rows = explode("'n", $items);  
    foreach($rows as $item)
    {
        if($item === $checkitem)
            return TRUE;
    }
    return FALSE;
}

我已经确认它的回报是准确的并且工作正常。这是调用函数的地方,我遇到了一个问题:

$email = sanitizeInput($_POST['email']);
$email = strtolower($email);
$emails = file_get_contents('emails.txt');
if(checkForDuplicates($emails, $email) == FALSE);
{
    $emailFile = fopen('emails.txt','a') or die ('Sorry. Subscriptions are disabled for the time being.');
    fwrite($emailFile, $email."'n");
    fclose($emailFile);
}

无论我输入什么,它都会以任何一种方式写入文件。我不可能理解为什么这么简单的比较不起作用。

你的问题来自这里的尾随";"

if(checkForDuplicates($emails, $email) == FALSE);

它归结为带有空语句的 if。

始终执行以下块(文件追加),因为它不是条件的一部分。