When we first developed the project, we needed error prompts very much, but after the project went online, we certainly didn’t want to display these error prompts, right?This is about to do some settings, often a lot of PHP novice, do not know how to set?Or the setting method is wrong.
1、 The setting method of the project under development:
1. Open php.ini
2. Set error_ reporting = E_ ALL
3. Set display_ errors = On
2、 The setting method after the project is really online:
1. Open php.ini
2. Set error_ reporting = E_ ALL & ~ E_ DEPRECATED & ~ E_ STRICT
3. Set display_ errors = Off
3、 If you don’t have permission to modify php.ini, you can add the following two lines of code directly to the PHP file:
1、ini_ set(“display_ errors”, “On”);
2、error_ reporting(E_ ALL | E_ STRICT);
be careful:
First, after modifying the configuration file php.ini, be sure to restart the service.
Second, error_ The value of reporting can be modified at will. It is suggested to modify it according to your project development situation: is it under development?Or is it online?error_ What are the specific values of reporting?I’ll talk about it in the following expanded knowledge.
Expand knowledge:
Maybe some of them don’t understand the above settings. Let’s talk about it in detail: error_ Reporting represents the error level, display_ Errors represents whether error prompts are displayed.
error_ Reporting error levels include the following:
E_ All – all errors and warnings (including E_ STRICT)
E_ Error – fatal runtime error
E_ RECOVERABLE_ Error – a nearly fatal runtime error
E_ Warning – runtime warning (non fatal error)
E_ Parse – compile time parsing error
E_ Note – runtime notifications (these are usually warnings from errors in your code, but it may be intentional (for example, using uninitialized variables and relying on it to automatically initialize to a fact empty string)
E_ Strict – runtime notification that allows PHP to suggest changes to your code will ensure optimal interoperability and forward code compatibility
E_ CORE_ Error – fatal error during initial PHP startup
E_ CORE_ Warning – a warning (non fatal error) that occurs during PHP, initial startup
E_ COMPILE_ Error – fatal compile time error
E_ COMPILE_ Warning – compile time warning (non fatal error)
E_ USER_ Error – user generated error message
E_ USER_ Warning – user generated warning message
E_ USER_ Note – user generated notification message
E_ Suppressed – warning code will not work in future versions of PHP
E_ USER_ Suppressed – user generated discard warning
error_ The most common settings of reporting are as follows:
E_ All (displays all errors, warnings and notifications, including coding standards.)
E_ ALL & ~ E_ Note (show all errors except notification)
E_ ALL & ~ E_ NOTICE & ~ E_ Strict displays all errors except notification and coding standard warnings.)
E_ COMPILE_ ERROR|E_ RECOVERABLE_ ERROR|E_ ERROR|E_ CORE_ Error (display error only)