What common syntax errors or pitfalls should PHP developers be aware of when using if statements in their code?

One common syntax error when using if statements in PHP is forgetting to include parentheses around the condition. Another pitfall is using a single equal sign (=) instead of a double equal sign (==) for comparison. To avoid these errors, always ensure that the condition is enclosed in parentheses and use double equal signs for comparison.

// Incorrect way of using if statement
if $x == 5 {
    echo "x is equal to 5";
}

// Correct way of using if statement
if ($x == 5) {
    echo "x is equal to 5";
}