Home >Backend Development >PHP Problem >What is the difference between php== and ===?
What is the difference between == and ===? The following article will introduce it to you. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
The difference between === and == in php
===Compare the value and type of two variables; == Compares the values of two variables, not the data types.
For example:
$a = '123'; $b = 123; $a === $b //为假; $a == $b //为真;
In some cases you cannot use ==, you can use ===, for example:
<?php $a = 'abc'; $b= 'a'; if(strpos($a,$b) === false){ echo '字符串不包含'; }else{ echo '字符串包含'; } ?>
If you use ==, the output will be "The string does not contain ”, which is inconsistent with reality.
For more related knowledge, please pay attention to PHP Chinese website! !
The above is the detailed content of What is the difference between php== and ===?. For more information, please follow other related articles on the PHP Chinese website!