Using the PHP Function Ini_Get
The php function ini_get allows developers to change configuration settings set in the php.ini file at runtime. This can include disabling the error screen display or logging errors to file.
Seeing errors is essential for any developer when debugging a misbehaving application. Error messages are vital for identifying syntax errors (such as missing semicolons), pointing out inconsistencies in the code, and revealing more complex issues that need to be investigated further such as an undefined method call. Without error displays, debugging a PHP application becomes a guessing game.
PHP also provides the ability to log notices, warnings and errors via the error_reporting() function. The error_reporting() function accepts a list of error-level constants such as E_ERROR, E_WARNING and E_PARSE. Using bitwise operators, a developer can configure the error_reporting() function to report all levels of errors or specific ones such as E_NOTICE only.
In order to configure which types of errors should be displayed and logged, the php function ini_get() can be used to override the default configuration set by the PHP.ini file using an INI value. The ini_get() function returns a value of 0 or a string representation of the INI file value if successful.
Using the ini_get() function in PHP, a developer can create custom exception classes that will be thrown and caught by the base PHP exception class. For example, an Exception class could be created to handle incidences of too many login attempts. This would be a good way to identify and correct issues in an application that might not be able to handle too much traffic.