What are some best practices for optimizing boolean evaluation in PHP code?

When optimizing boolean evaluation in PHP code, it is best to use strict comparison operators (=== and !==) instead of loose comparison operators (== and !=) to ensure both value and type are checked. Additionally, avoid unnecessary negations and complex conditions by simplifying the logic where possible. Lastly, consider using short-circuit evaluation to improve performance by stopping evaluation as soon as the result is determined.

// Before optimization
if ($var == true) {
    // Do something
}

// After optimization
if ($var === true) {
    // Do something
}