How to reduce the number of if-else statements in PHP?
问题 I found that there are many if-else statements, especially nested if else statements, these statements make my code less readable. How to reduce the number of if else statements in PHP? My tips are as follows: 1.Use a switch statement when it is suitable; 2.use exit() statement when it is feasible; 3. Use ternary statement when it is feasible; Are there other tips that can reduce if else statements, especially nested if-else statements? 回答1: Refactor your code into smaller work units. Too