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 to implement skipping when encountering errors in php

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces php how to achieve error skip, the article is very detailed, has a certain reference value, interested friends must read it!

1. Open the corresponding PHP code file.

2. you can suppress the error by displaying it with the @ error control operator.

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.

The above is all the contents of the article "how to skip errors encountered by php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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