= And the difference between == and ===

  In php, "=" and "==" and "===" is not the same effect in the determination executed statement.

  =: For example the following code:

  

 

 

   "=" Is the assignment operator, which means that the right to the left will assignment expression operand set value. 7 corresponds to the if statement types assigned to the variable d, and 7 is true, thus performs the echo 1;

 

  ==: comparison operators, see the following code

 

 

    After performing the above code can be verified, if the type of conversion $ a  is equal to  $ b was true, the number 7 and 8 with an int number, but is clearly not equal to 7 8, and therefore is not performed echo 0. Switch bool and int 2 is true, then echo 1 is performed. Similarly several conditions have to the rest of the judgment.

   ===: Comparison operators, all equal. If $ a  is equal to  $ b , and they are the same type was also true.

 

   Thus, the two variables do not === after comparison conversion type, a direct comparison of the value of its content, the number 0 is not equal to the character 0, 0 === therefore "0" is false.

  the above.

Guess you like

Origin www.cnblogs.com/smallzhen/p/11870243.html