About error report level settings in php.ini

Source: Internet
Author: User
Tags coding standards

Recently, in the process of writing PHP found PHP hint PHP notice: ..... ..... The words, although this is only PHP hint content, and no big impact, but for security and aesthetic considerations, the younger brother still want to remove this thing. So, what do we do? To carry out Baidu, directly copy, paste PHP notice:, so search results, generally there are two situations: first, directly to a sentence: Error_reporting=e_all&~e_notice, make you do not know what meaning?! Ii. 1. In the php.ini file, change error_reporting to: Error_reporting=e_all&~e_ NOTICE If you are unable to manipulate the php.ini file, you can use the following method to implement 2. Add the following code to the page where you want to suppress the NOTICE error message */Report all errors except E_notice */error_ Reporting (e_all ^ e_notice); Hopefully the code above will solve your problem. This is OK, let you know how to do! Open php.ini,ctrl+f Find error_reporting, put the above Ctrl + V to browse their own web page, ah, really do not show PHP notice, at this time really grateful to the eldest brother, finally help us these rookie to solve the problem. However, do not rush to close php.ini, let us take a good look at our php.ini:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Error handling and logging;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;  Error_reporting is a bit-field. Or each number up to get desired error; Reporting level; E_all-all errors and warnings (doesn ' t include e_strict); E_error-fatal run-time errors; E_recoverable_error-almost Fatal run-time errors; E_warning-run-time warnings (non-fatal errors);  E_parse         -Compile-time parse errors;                     E_notice-run-time Notices (these is warnings which often result;                     From a bug in your code, but it's possible that it was;                     Intentional (e.g., using an uninitialized variable and;                     Relying on the fact it's automatically initialized to an; empty string);                     E_strict-run-time notices, enable to has PHP suggest changes;                     To your code which would ensure the best interoperability; And forward compatibility of your code; E_core_error-fatal errors that occur during PHP ' s initial startup;                     E_core_warning-warnings (non-fatal errors) that occur during PHP ' s; Initial startup; E_compile_error-fatal compile-time errors; E_compile_warning-compile-time warnings (non-fatal errors); e_user_error-user-generated ERROR message; e_user_warning-user-generated WARNING message; E_user_notice     -user-generated notice message;;   Examples:;; -Show all errors, except for notices and coding standards warnings;   error_reporting = E_all & ~e_notice;; -Show all errors, except for notices;; error_reporting = e_all & ~e_notice |   E_strict;; -Show only errors;; error_reporting = e_compile_error| e_recoverable_error| e_error|   E_core_error;; -Show all errors, except coding standards warnings;error_reporting = E_all Although it is in English, but just a few English words, it should be hard not to pour us! After reading, you will find that the solution to the search seems not good, but should be: to remove; error_reporting = e_all & ~e_notice This sentence is comprehensive; This is easier than the search solution, and it also guarantees the integrity of the php.ini. Now, take a look at the error reporting level control in the Web page! Take out your PHP manual, index->error_reporting, and see it! The error_reporting () function sets the error_reporting directive at runtime. PHP has many levels of errors, using the This function sets a level for the duration (runtime) of your script. Parameter level the N EW error_reporting level. It takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for FUTUre versions. As error levels is added, the range of integers increases, so older integer-based error levels won't always behave as Expected. The available error level constants is listed below. The actual meanings of these error levels is described in the predefined constants. Table 82.error_reporting () level constants and bit Valuesvalue constant 1 e_error 2 e_warning 4 e_parse 8 e_notice + e_core_error e_core_warning OR e_compile_warning e_user_error e_user_warning 1024x768 e_user_notice 2047 e_all 2048 e_strict 4096 E_RECOVERABL E_error return value returns the old Error_reporting level. Example 543.error_reporting () examplescopy to clipboard<?php//Turn off All error reportingerror_reporting (0);//Report Simple running errorserror_reporting (E_error | e_warning | E_parse);//Reporting e_notice can be good too, to report uninitialized//variables or catch variable name misspellings. .) Error_reporting (E_error | e_warning | E_parse | E_notice);//Report all errors excepte_notice//the default value set in Php.inierror_reporting (e_all ^ e_notice);//Report All PHP errors (bitwise 63 May is used in PHP 3) error_reporting (e_all);//Same as error_reporting (E_all); Ini_set (' error_reporting ', e_all);? >

  

About error report level settings in php.ini

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.