Possible Duplicate:
The 3 different equals可能重复:3个不同的等于
Is there any difference between == and === in php? both seem to work fine for me when i use them in a conditional statement. I am very new to programming in PHP. Please consider this and answer in simple words.
php中==和===之间有什么区别吗?当我在条件语句中使用它们时,两者似乎都适合我。我是用PHP编程的新手。请考虑一下并用简单的话回答。
2 个解决方案
#1
12
$a == $b
- $ a == $ b
Equal true: if $a
is equal to $b
, after type juggling.
等于true:如果$ a等于$ b,则在类型杂耍之后。
$a === $b
- $ a === $ b
Identical true: if $a
is equal to $b
, and they are of the same type.
完全相同:如果$ a等于$ b,则它们属于同一类型。
#2
4
Identical:
$a === $b
$ a === $ b
TRUE
if $a
is equal
to $b
, and they are of the same type. (introduced in PHP 4
)
如果$ a等于$ b,则为TRUE,它们属于同一类型。 (在PHP 4中引入)
Equal:
$a == $b
$ a == $ b
TRUE
if $a
is equal to $b
after type juggling.
如果在类型杂耍之后$ a等于$ b,则为TRUE。
Read here for more: http://www.php.net/manual/en/language.operators.comparison.php
请阅读此处了解更多信息:http://www.php.net/manual/en/language.operators.comparison.php
#1
12
$a == $b
- $ a == $ b
Equal true: if $a
is equal to $b
, after type juggling.
等于true:如果$ a等于$ b,则在类型杂耍之后。
$a === $b
- $ a === $ b
Identical true: if $a
is equal to $b
, and they are of the same type.
完全相同:如果$ a等于$ b,则它们属于同一类型。
#2
4
Identical:
$a === $b
$ a === $ b
TRUE
if $a
is equal
to $b
, and they are of the same type. (introduced in PHP 4
)
如果$ a等于$ b,则为TRUE,它们属于同一类型。 (在PHP 4中引入)
Equal:
$a == $b
$ a == $ b
TRUE
if $a
is equal to $b
after type juggling.
如果在类型杂耍之后$ a等于$ b,则为TRUE。
Read here for more: http://www.php.net/manual/en/language.operators.comparison.php
请阅读此处了解更多信息:http://www.php.net/manual/en/language.operators.comparison.php