Example Analysis of PHP Code Optimization
This article mainly introduces the PHP code optimization example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
A short "shoddy" PHP code optimization process, please carefully understand the optimization process
The following short "shoddy" PHP code is a simplified test question. This question is like asking: how do you optimize this code?
The main problem with this code is that it displays the data submitted by the user directly on the web page, thus creating a XSS vulnerability. In fact, there are many ways to close this loophole. So, what kind of code do we want?
This is the minimum requirement. The XSS loophole is filled with the htmlspecialchars function, thus masking illegal characters.
Then optimize: