PHP Error control operator

Source: Internet
Author: User

PHP supports an error control operator: @. Any error messages that may be generated by the expression are ignored until it is placed in a PHP expression.

If an attribute is activated, any error information generated by the expression is stored in the variable $php _errormsg. This variable is overwritten every time an error occurs, so check it out as soon as possible if you want to use it.

<?php/* Intentional File Error */$my _file = @file (' non_existent_file ') or Die    ("Failed opening file:error is ' $p Hp_errormsg ' ");//This works for any expression, not just functions: $value = @ $cache [$key];//would not issue a notice if T He index $key doesn ' t exist.? >

Note: The @ operator is only valid for an expression. A simple rule for beginners is that if you can get a value from somewhere, you can precede it with the @ operator. For example, you can put it in variables, functions and include () calls, constants, and so forth. It cannot be placed before the definition of a function or class, nor can it be used for conditional structures such as if and foreach.

Warning

The current "@" error control operator prefix even invalidates the fatal error report that caused the script to terminate. This means that if "@" is used to suppress the error message before a function call that does not exist or is of the wrong type, the script will die there without any indication of why.

Http://blog.sina.com.cn/s/blog_1603d3c730102wgz8.html

Http://blog.sina.com.cn/s/blog_1603d3c730102wgz9.html

Http://blog.sina.com.cn/s/blog_1603d3c730102wgza.html

Http://blog.sina.com.cn/s/blog_1603d3c730102wgzb.html

PHP Error control operator

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.