To use thinkphp to develop templates, you need to write a lot of judgments to read the desired data. For example, you need to write 30 IF ELSEIF judgments. Will it affect the page speed? Is there a better solution
To use thinkphp to develop templates, you need to write a lot of judgments to read the desired data. For example, you need to write 30 IF ELSEIF judgments. Will it affect the page speed? Is there a better solution
If the level of the set is very deep, then it is better for you to change your logic.
If the level is not deep, it is normal. You can use switch, or extract some if conditions that need to be judged, and convert them into bool variables on the back end.
The first rendering of the page will definitely be slower. You can use caching in the future. It is normal to have if else in the module. .
The data is parsed in advance in the background and then transmitted to the front desk.
Use switch for the template
If there are more than two ifelse, it is recommended to use switch
Give the semaphore
and then use switch
30 if elseifs? So many??
You can use switch case to simplify if elseif statements
It’s best to use arrays
Customize a function, write these logic into the function, and then call it in the template. As for many judgments, if you can change the background logic, simplify it.
You should look at your business logic to see if it can be optimized