What are the potential pitfalls of using if statements in PHP code?

One potential pitfall of using if statements in PHP code is that it can lead to nested if statements, making the code harder to read and maintain. To avoid this, consider using switch statements or refactoring the code into separate functions. Additionally, using if statements without proper error handling can result in unexpected behavior if conditions are not met.

// Example of refactoring nested if statements into separate functions
function checkCondition1($param) {
    if ($param > 0) {
        return true;
    } else {
        return false;
    }
}

function checkCondition2($param) {
    if ($param < 10) {
        return true;
    } else {
        return false;
    }
}

// Usage
$number = 5;

if (checkCondition1($number) && checkCondition2($number)) {
    // Code block to execute if both conditions are met
}