What are the potential pitfalls of using assignment operators instead of comparison operators in PHP conditional statements?

Using assignment operators instead of comparison operators in PHP conditional statements can lead to unintended consequences and logical errors in your code. This is because assignment operators like "=" will assign a value to a variable, rather than comparing two values for equality. To avoid this issue, always use comparison operators like "==" or "===" when writing conditional statements in PHP.

// Incorrect usage of assignment operator in conditional statement
$number = 5;

if ($number = 10) {
    echo "Number is 10";
} else {
    echo "Number is not 10";
}

// Correct usage of comparison operator in conditional statement
$number = 5;

if ($number == 10) {
    echo "Number is 10";
} else {
    echo "Number is not 10";
}