Error handlingLOGIN

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:

  1. The file path and file storage specifications of the server
  2. Some people like to use personal names to name them through social engineering Learn how to reversely deduce the password
  3. 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:

<?php

$fp = fopen('abc.txt','a+')

fwrite($fp,'abc');

fclose($fp);
?>

An error was reported:

document/2015-09-22/560126786806a

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.

Next Section
submitReset Code
ChapterCourseware