Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php skip when it encounters an error

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report