How does php skip when it encounters an error
How does php skip when it encounters a mistake? I believe many inexperienced people are at a loss about it. Therefore, this article summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Php encountered errors to skip the implementation methods: 1, open the corresponding PHP code file; 2, through the @ error control operator to suppress the error.
This article operating environment: windows7 system, PHP7.1 version, Dell G3 computer.
How does php skip when it encounters an error?
PHP skips the error to continue execution:
The @ error control operator can do this.
The @ symbol can ignore errors and has the function of suppressing errors.
For example:
Function db_connect () / / Connect to database {@ $db = mysql_connect ('localhost','root','test'); if (! $db) {throw new Exception (' failed to connect to database! Please try again!');} mysql_select_db ('book'); return $db;}
If the connection to the database is not successful, the previous "@" will be able to suppress the error, that is, it will not show the error, and then throw an exception to show the self-defined exception handling. It is recommended to use less, which will increase the system overhead.
After reading the above, have you mastered how php skips when it encounters an error? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!