Home  >  Q&A  >  body text

3 different equals

What is the difference between

=, ==, ===?

I think using one equal sign is to declare a variable, two equal signs are used to compare conditions, and the last three equal signs are used to compare the value of the declared variable.

P粉134288794P粉134288794188 days ago326

reply all(2)I'll reply

  • P粉545956597

    P粉5459565972024-03-20 10:07:34

    • = is the assignment operator
    • <代码>== is a comparison operator (checks if Both variables have the same value)
    • === is the same comparison operator (checks whether two variables have the same value and are the same type).

    reply
    0
  • P粉899950720

    P粉8999507202024-03-20 00:40:22

    You have = assignment operator , == "equals" comparison operator and === "Same" comparison operator.

    $a = $b Assign Sets $a to be equal to $b.
    $a == $b Equal TRUE if $a is equal to $b.
    $a === $b Identical TRUE if $a is equal to $b, and they are of the same type. (introduced in PHP 4)
    

    For more information on the necessity of == and === and their respective usage, see Documentation.

    reply
    0
  • Cancelreply