您的逻辑是:(!):
!$mail['to_id'] == $account['id']
&&
!$mail['from_id'] == $account['id']
问题从做这源于
!$mail['to_id']
和
!$mail['from_id']
逆算子翻转的价值它被应用于什么。在这种情况下,您正在翻转$ mail ID的值。这可能不会做你想做的事情,因为这些ID,我假设,是整数。
它可能有助于在积极思考这个,然后反向整个事情。
值得肯定的是:“!”
$mail['to_id'] == $account['id']
&&
$mail['from_id'] == $account['id']
它的倒数被包裹了整个事情的(注意括号):
!(
$mail['to_id'] == $account['id']
&&
$mail['from_id'] == $account['id']
)
我们可以使用代数规则将该语句乘以“!”针对每个元素(包括AND运算符)。
!($mail['to_id'] == $account['id']) // Note you apply the inverse of to the whole expression
!&& // this isn't an actual code but for demonstration purposes
!($mail['from_id'] == $account['id']) // Note you apply the inverse of to the whole expression
它简化成:
$mail['to_id'] != $account['id'] // Not Equal is inverse of equal
|| // the inverse of && (AND) is || (OR)
$mail['from_id'] != $account['id'] // Not Equal is inverse of equal
其中规定:
“如果MAIL_TO OR Mail_From ID不匹配的帐户ID,请执行以下代码”
因此,在一天结束时,您应该可以使用:
if($mail['to_id'] != $account['id'] || $mail['from_id'] != $account['id'])
{
// do something
}
或
if(!($mail['to_id'] == $account['id'] && $mail['from_id'] == $account['id']))
{
// do something
}
两人都说同样的事情。
我希望有帮助!
你应该添加更多的代码。还是只是我是一个不好的读者? – jtheman 2013-05-09 21:30:33
*但是当我加入!=而不是== *你是否删除每个值后面的'!'? – christopher 2013-05-09 21:30:44
是的,我确实删除了它们。编辑:我忘了从两个值中取出来,谢谢你的帮助。 – Malik 2013-05-09 21:32:03