How can the order of parentheses affect the outcome of a SQL query in PHP?

The order of parentheses in a SQL query in PHP can affect the outcome by changing the logical grouping of conditions. To ensure the desired logic is applied, it is important to carefully place parentheses around conditions to control the order of evaluation. Example PHP code snippet:

$query = "SELECT * FROM table WHERE (condition1 AND condition2) OR condition3";