ProAnswers.org

what is use of .ini files in PHP?

1 Like

It is used as a php configuration file. generally php.ini is used on apache like servers

The common INI file used in PHP is the php.ini file;
it has the ability to set values for directives (variables) that are silently scanned and interpreted as scripts are performed.

PHP users can create their own INI files with the parse_ini_file function.

INI-type files are one way of setting PHP environment variables – variables that can affect how PHP is ran, what functions are available during runtime, how superglobal variables are filled, and more.

php.ini

The most common INI file used in PHP is the php.ini file; it has the ability to set values for directives (variables) that are silently scanned and interpreted as scripts are performed.

For example, if a script ran the “define” function, it can check the php.ini file’s “disable_functions” directive (which can be a list of disabled functions) for the “define” function. If the function is listed, the function is not ran because it has been declared disabled through php.ini.

The php.ini file can only define values for its standard, core directives; if you want to use custom directives that don’t have anything to do with the core or extensions of PHP, you will want to create your own INI file!

Custom INI files

PHP users can create their own INI files that can be scanned with the parse_ini_file function and placed into an array. Scripts can later perform depending on the values set in the custom INI file (or completely ignore the scanned values).

For example, in the custom INI file, you could have a directive named “theme” and it could be set to “red” or “blue.” If it is “red,” the script prints CSS in a page’s header to make the background color of that page red. If it is “blue,” it will have a blue background.