What are some common logical errors to watch out for when writing conditional statements in PHP?

One common logical error to watch out for when writing conditional statements in PHP is using assignment operators (=) instead of comparison operators (== or ===). This can lead to unintended consequences as the assignment operator will always return true, resulting in unexpected behavior. To avoid this issue, always use comparison operators when checking conditions in PHP.

// Incorrect usage of assignment operator instead of comparison operator
$age = 18;

if($age = 18) {
    echo "You are 18 years old.";
}

// Corrected code using comparison operator
$age = 18;

if($age == 18) {
    echo "You are 18 years old.";
}