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

What are the error control operators in php

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

Share

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

This article will explain in detail what the error control operators in php are, and the content of the article is of high quality, so the editor will share it with you for reference. I hope you will have some understanding of the relevant knowledge after reading this article.

The error control operator in php is "@", and any error messages that may be generated by an PHP expression will be ignored. The "@" operator is only valid for expressions, it can precede variables, functions, include calls, constants, and so on, but not before the definition of a function or class.

Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

Php error control operator: @

PHP supports the use of the error control operator @. Any error messages that may be generated by an PHP expression will be ignored before it is placed.

If you set a custom error handler with set_error_handler (), the error handler will still be called, and if @ is used before the error statement, the error handler will return 0.

It is important to note that the @ operator is valid only for expressions. To put it simply, if you can get a value from somewhere, you can precede it with the @ operator. For example, you can use the @ operator before variables, functions, include calls, constants, and so on, but it cannot be placed before the definition of a function or class, nor can it be used before conditional structures such as if and foreach statements.

The @ operator is also valid for serious errors that can cause the program to terminate, which means that if @ is used to suppress the error message before a function call that does not exist or typed the wrong letter, the program will die there without any hint.

[example] use the @ error operator to mask errors in the code.

The running results are as follows:

Database connection failed! On the error control operators in php which are shared here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

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