While installing PHP, this file is provided with PHP installation settings. For that, it includes set of directives provided with respective values. These directives are of two types based on the values they have. These are,
This file has two sections based on which the value and flag directives can be set with. These sections are,
[HOST="www.somedomain.com"] display_errors = off
This setting will not allow to display error, while running our PHP project in this host.
display_errors = on
This file is located inside php folder of the location where we have installed PHP. If we use XAMPP package, we could find this file in \xampp\php.
After installing PHP, we can find one or more versions of php.ini file. We need to choose any one of the preferable version that should be renamed as php.ini. For example, if those versions are named as php.ini_dist and php.ini_recommended, then we need to select the later one. Because, it is optimized file with respect to performance, security and etc. So, we need to rename php_ini_recommended as php.ini
If we use XAMPP package to install PHP in our local machine, then there will be another set of two versions of this file, that is, php.ini-development and php.ini-production. Among them, php.ini-development is preferable than the other to rename as php.ini.
We can make changes with this file on demand basis. For example, if we want to access the remote file, we need to set the option allow_url_fopen to be enabled. After making any change with either php.ini, we need to restart our XAMPP server (or any package using which the PHP is installed) to make these changes to be effective in our PHP environment.
This file includes settings related to the PHP environment features like error handling, remote access, file uploads, configuring image related settings, for example setting maximum size of images to upload and etc.
This file also have directives to configure with session and cookie related settings. But, some of the php.ini directives are deprecated as of later versions of PHP.
We can also customize php.ini file as our own by following the default template of this file provided while installing PHP. By customizing own php.ini file we can configure our PHP environment on need basis.
This PHP code tutorial was published on May 21, 2013.