What are common syntax errors in PHP code that can lead to unexpected behavior, such as the use of semicolons in if and elseif statements?

One common syntax error in PHP code that can lead to unexpected behavior is the misuse of semicolons in if and elseif statements. When using if and elseif statements in PHP, the condition should be enclosed in parentheses and the code block should not end with a semicolon. Adding a semicolon at the end of the if or elseif statement can cause the code block to execute regardless of the condition, leading to unexpected behavior.

// Incorrect usage of semicolon in if statement
if ($condition); {
    // Code block to execute
}

// Corrected code without semicolon after if statement
if ($condition) {
    // Code block to execute
}