Are there any common pitfalls when using the assignment operator instead of the comparison operator in PHP?

Using the assignment operator "=" instead of the comparison operator "==" in PHP can lead to unintended consequences, as it will assign a value rather than compare two values. To avoid this pitfall, always double-check your code and use the correct operator for the intended operation.

// Incorrect usage of assignment operator
$variable = 10;

if($variable = 5){
    echo "This will always be true!";
}

// Correct usage of comparison operator
$variable = 10;

if($variable == 5){
    echo "This will not be executed.";
}