![](/img/trans.png)
[英]PHP - What is the difference between '!== false' and ' == true'?
[英]What is the difference between an if (true)/else (false) and a if(!true) in php?
if (${"old_tag_$x"} == $tag) {
} else {
${"old_tag_$x"} = $tag;
setTermFieldbyId('tag', $tag, $x);
}
這很好。 但是,它看起來確實很羅word,因此我嘗試將其簡化為:
if (!${"old_tag_$x"} == $tag) {
${"old_tag_$x"} = $tag;
setTermFieldbyId('tag', $tag, $x);
}
但是,這根本不起作用。 仍在弄清楚事情,但是對我來說這似乎不合邏輯。 我錯了嗎?
它應該是
if (${"old_tag_$x"} != $tag) {
${"old_tag_$x"} = $tag;
setTermFieldbyId('tag', $tag, $x);
}
http://www.php.net/manual/zh/language.operators.comparison.php
從手冊:
$ a!= $ b不等於類型雜耍后,如果$ a不等於$ b,則為TRUE。
還要注意==
和===
(或!=
和!==
)是不同的。 ==
比===
更寬松。 ===
要求變量類型匹配(例如,字符串等於字符串,或者整數等於整數)。
例如:
1 =='1'
是真的,但是
1 ==='1'
是假的
這也是指向此文檔的鏈接, http://php.net/manual/en/types.comparisons.php 。 這是此功能的演示, http://sandbox.onlinephpfunctions.com/code/70adc739a1062ee91944b7bf75574643946ecc17
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.