What common mistakes can occur when using if and else statements in PHP scripts?

One common mistake when using if and else statements in PHP scripts is forgetting to include curly braces {} when there are multiple lines of code to be executed within the if or else block. This can lead to unexpected behavior and errors in the script. To solve this issue, always use curly braces to encapsulate the code within the if and else blocks.

// Incorrect way without curly braces
if ($condition)
    echo "Condition is true";
    echo "This line will always be executed";

// Correct way with curly braces
if ($condition) {
    echo "Condition is true";
    echo "This line will only be executed if the condition is true";
}