Error handling
In the past, when we were writing code, we often saw: the function name was written incorrectly, the semicolon was forgotten, and the function was redefined, various errors would be reported.
In development, displaying errors is very beneficial to our development. Because displaying errors can help us quickly locate errors and solve problems.
In the production environment (i.e., public network), websites, microsites, mobile websites, mobile interfaces, etc. are accessible to others.
If the error is displayed, it is easy to expose:
- The file path and file storage specifications of the server
- Some people like to use personal names to name them through social engineering Learn how to reversely deduce the password
- Sometimes the address of the mysql database server is exposed
... ...etc.
The above information is particularly easy to be used with ulterior motives on the Internet Some people take advantage of it.
For example, in the following code, we fully expose our server-side file storage path, framework information, etc. without adding semicolons. As follows:
An error was reported:
The Chinese translation of the error message is:
Parse error: syntax error. The accident occurred near line 5 of fwrite in the /home/vagrant/Code/Laravel/public/index.php file.
Then, how should we solve it?
——This requires studying our error handling chapter.