What are some best practices for optimizing condition statements in PHP, especially when dealing with multiple conditions?

When dealing with multiple conditions in PHP, it is important to optimize your condition statements to improve code readability and maintainability. One best practice is to use logical operators such as && (AND), || (OR), and ! (NOT) to combine conditions effectively. Additionally, consider using switch statements for cases where you have multiple conditions to check against a single variable.

// Example of optimizing condition statements in PHP

// Bad practice
if ($condition1) {
    if ($condition2) {
        // Code block
    }
}

// Good practice
if ($condition1 && $condition2) {
    // Code block
}

// Using switch statement
switch ($variable) {
    case 'value1':
        // Code block
        break;
    case 'value2':
        // Code block
        break;
    default:
        // Default code block
}