我想比較兩個字符串,我從HTML中的密碼錶單中獲得。php中的字符串比較
它們存儲在$_POST
的變量中。我將它們打印出來,它們看起來是一樣的,但下面的代碼永遠不會評估爲真,只是假。爲什麼會發生?
//Verify the passwords match
if(($passwd != $pass_confirm) && ($new_email != $email_confirm)){
echo "Email and/or password do not match";
return FALSE;
}
我很感激任何幫助。
如果這是一個功能的一部分(return語句表明這一點),那麼不要忘記返回「真」。然後,正如其他人已經回答,使用**或**而不是**和**。 – martinstoeckli 2012-04-05 12:27:25