Info
Open the page on your phone

What is the difference between =, == and ===?

In the PHP programming language, the operators =, ==, and === have the following distinctions:

1. `=` (assignment):

    * Used to assign a value to a variable.

    * Example: `$a = 10;` - this assigns the value `10` to the variable `$a`.

2. `==` (value comparison):

    * Compares the values of two expressions and returns `true` if they are equal after type coercion, and `false` otherwise.

    * Example: `$a == $b` - this compares the values of the variables `$a and $b`.

3. `===` (strict comparison):

    * This is a strict comparison operator that considers both the values and types of the operands.

    * Returns `true` if both the values and types of the operands are identical, and `false` otherwise.

    * Example: `$a === $b` - this is a strict comparison of the values and types of the variables `$a and $b`.

                        
$a = 5;    // assignment
$b = "5";

var_dump($a == $b);    // true, because values are equal (non-strict comparison)
var_dump($a === $b);   // false, because values are different or types are different (strict comparison)
                        
                    

In PHP, `==` may perform automatic type coercion during comparison, while `===` uses strict comparison without automatic type coercion.