php.ini File

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,

  1. Value Directive – It contains values with respect to the name of the directive. For example, include_path is a value directive that holds the default path to be included, if no URL is specified for the PHP include() function.
  2. Flag directive – It is considered as flags that can be set or unset by using boolean terms, like, on/off, 1/0, true/false and etc. For example, REGISTER_GLOBALS set to off by default, since register_globals are deprecated in PHP.


This file has two sections based on which the value and flag directives can be set with. These sections are,

    1. HOST – The directives can be set for the host name specified using this section. (i.e.) settings under particular host name will be work only with that host. For example,
      display_errors = off

      This setting will not allow displaying error, while running our PHP project in this host.

    2. PATH – Here configuration are set with particular path specified. For example,
      display_errors = on

Configuring php.ini

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 a 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 an 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 on 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.


Change of Impact

We can make changes to 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.

php.ini Settings

This file includes settings related to the PHP environment features like error handling, remote access, file uploads, configuring image related settings, for example setting the maximum size of images to upload and etc.

This file also has 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 a need basis.

This PHP code tutorial was published on May 21, 2013.

↑ Back to Top