How to optimize IF nesting? IF conditions like this can be written again, you should not use a switch. after all, you must determine the time, number of times, IP address, and other conditions.
If (access period ){
Echo "normal time period ";
If (ID range ){
Echo "normal ID range ";
If (number of visits ){
Echo "normal access times ";
If (IP address ){
Echo "normal IP address ";
} Else {
Echo "wrong IP address ";
}
} Else {
Echo "too many accesses ";
}
} Else {
Echo "error ID range ";
}
}
Else {
Echo "pay attention to rest ";
}
Reply to discussion (solution)
Parallel writing
While (true) {if (access period) {echo "normal period";} else {echo "note rest"; break;} if (ID range) {echo "normal ID range";} else {echo "error ID range"; break;} if (access count) {echo "normal access count ";} else {echo "too many accesses"; break;} if (IP address) {echo "normal IP address";} else {echo "wrong IP address"; break ;}
$ Error = 0; if (access time period) {echo "normal time period"; else {$ error = 1; echo "pay attention to rest ";} if ($ error = 0 & ID range) {echo "normal ID range";} else {$ error = 1; echo "error ID range ";} if ($ error = 0 & access times) {echo "normal access times" ;}else {$ error = 1; echo "excessive access times ";} if ($ error = 0 & IP address) {echo "normal IP address";} else {$ error = 1; echo "error IP address ";}
The parallel structure on the second floor is easy to understand. the parallel structure on the third floor has never been used ......