Ways to mask Notice warnings in PHP default settings _php tips

Source: Internet
Author: User

The default setting for PHP is to display notice warning prompts, which can cause the page to not display properly. You have no defined variables to use directly. However, when editing PHP is not as strict as C + +, programming often will use this feature.
In the hard to write their own PHP program deployed to the server, I believe such a hint many people have seen:

PHP notice:undefined variable  
php notice:undefined index 

Look, you have undefined variables to use directly. However, when editing PHP is not as strict as C + +, programming often will use this feature. The default setting for PHP is to display these prompts, which can cause the page to not display properly.

Error_reporting (E_all);  
Error_reporting (E_all | | ~e_notice); Show all error messages except E_notice 

The first one is to show all errors,
The second represents that all errors do not display a warning,
All we have to do is add the second line to the front//, and remove the first line//.

Attached: Each error report detailed
How to use:

Error_reporting (0)//Disable error Reporting  
error_reporting (e_all ^ e_notice);//Show all error messages except E_notice error_reporting  
(e_ All^e_warning^e_notice)//displays all error messages except e_warning e_notice  
error_reporting (E_error | e_warning | E_parse)//shows Run-time errors, with error_reporting (e_all ^ e_notice), the effect is the same.  
error_reporting (E_all);//Show All errors 

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.