What are the potential pitfalls of using if statements with assignment operators in PHP?

Using if statements with assignment operators in PHP can lead to unintended behavior or bugs. This is because the assignment operator (=) is used for assigning values, not for comparison. To avoid this issue, make sure to use comparison operators (== or ===) in your if statements instead of assignment operators.

// Incorrect usage of assignment operator in if statement
$number = 5;
if($number = 10) {
    echo "Number is 10";
}

// Corrected code using comparison operator
$number = 5;
if($number == 10) {
    echo "Number is 10";
}