PHP lets you specify the Error Reporting level, so that when a piece of your code is run based on this setting of the php.ini file the generated errors and/or warnings will be shown or not. Generally speaking in a development environment it is recommended to set this as high as possible so that you are informed about all the little details of your code whereas in a production environment this setting is usually set to something less “explanatory”.
In order to set the value of the error_reporting directive php constant values and bitwise operators are used, as they are described in the PHP manual . The setting can be set during runtime using the php error_reporting() function (manual) passing as a parameter the int value calculated based on the constant values and bitwise operators used. The function returns the integer value of the previous error_reporting level.
Now if you wish to find out what is your current error_reporting level you could go and have a look in your php.ini file or you could use the error_reporting() function with no parameters, in which case the function will return an integer value representing the current error reporting level. If you go via the php.ini file you will see the names of the constants used and the operations applied to produce your current reporting level but if you try to get a similar result via a php file that you have written you might notice that it is more difficult to understand what is going on since now you are only dealing with an integer value and not with the named constants. So which is the description of your error reporting level and how can you retrieve it from within a php file?
Continue reading “How to get your Error reporting constant values” →