开发者

What is the difference between == and === in php [duplicate]

开发者 https://www.devze.com 2023-03-12 19:22 出处:网络
This question already has answers here: How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?
This question already has answers here: How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ? (13 answers) Closed 5 months ago.

Is there any difference between == 开发者_开发问答and === in PHP? Both seem to work fine for me when i use them in a conditional statement.


  • $a == $b

Equal true: if $a is equal to $b, after type juggling.


  • $a === $b

Identical true: if $a is equal to $b, and they are of the same type.


Identical:

$a === $b

TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)

Equal:

$a == $b

TRUE if $a is equal to $b after type juggling.

Read here for more: http://www.php.net/manual/en/language.operators.comparison.php

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号