Changing PHP Configuration Options With the ini_set() Function
PHP allows you to alter configuration options that affect how a script is executed. These changes only last during the execution of a script, and are restored when the script finishes. Not all configuration options can be changed using ini_set(), however. Some configuration options are not accessible to the ini_set() function, because they have already been used or will be used in the future.
In addition to the ini_set() function, there are several other ways to change configuration settings in PHP, including using a global variable or an exception handler. Using these methods requires careful consideration and planning. For example, changing an error reporting value will also affect any errors that have been reported so far in the code.
Error messages are critical for developers because they indicate issues that need to be resolved in an application. These errors can include syntax errors such as missing semicolons, which are common mistakes that need to be fixed during development and testing. Without the ability to display these errors, troubleshooting a web application becomes difficult.
When a script executes, the first step that PHP takes is parsing INI files. This is where a lot of the configuration settings are declared. Afterwards, PHP boots up its extensions by calling their MINIT(). MINIT() can then register INI settings that the extension designers wish to make use of. Before a setting is registered, the engine checks if it has parsed this setting previously as part of the INI file parsing process. If this is the case, then it will reuse this value instead of creating a new one when using the ini_set() function. Otherwise, the engine will create a new value for this INI setting at runtime.