PHP Configuration Environment

As we know, when we install PHP in our local machine using wamp or xampp like a local server provider then sometimes we need to configure our PHP work environment and that means changing the PHP configuration setting. More than 45 extensions are provided in the latest versions of PHP. To use these extensions one must uncomment some of the lines in the PHP.ini file.


For example, if we want to enable PHP's XML-RPC extension then the following changes will be done in the PHP.ini file:

  1. Open the PHP.ini file and search for ;extension=PHP_xmlrpc.dll.

  2. Search for the line ;extension=PHP_xmlrpc.dll. Uncomment this line by removing the left-most (starting) semicolon. Save and close the file.

  3. Restart your web server and it's done.

PHP Runtime Configuration

PHP.ini file

The PHP.ini file is a global configuration file that contains important sections, like language, Syntax Highlighting, Miscellaneous, Resource Limits, Error Handling and Logging, Paths and Directories, File Uploads, Dynamic Extension and so on.

For example, if we want to allow a short tag in PHP like:

<? Echo <your code here> ?>

Then we should enable it from the PHP.ini file and change the code snippet to what is found in PHP.ini.

short_open_tag = Off

Change Off to On and restart your server and see the changes. Actually the changes take effect depending on our installation process of PHP. If we install our PHP as a CGI binary then the PHP.ini file is reread every time PHP is invoked, thus making the changes every time. If PHP is installed as an Apache module then it is read only once when we start our Apache server.

Apache httpd.conf and .htaccess Files

There are basically four types of configuration scope for security reasons so that not all directives can't be changed in the user's PHP script. These scope are:

  1. PHP_INI_PERDIR: Only modified within the PHP.ini, httpd.conf, or.htaccess files.
  2. PHP_INI_SYSTEM: This Only modified within the PHP.ini and httpd.conf files.
  3. PHP_INI_USER: This modified within user scripts.
  4. PHP_INI_ALL: This can be modified anywhere.

When PHP is running in an Apache module then we can modify many directives using the httpd.conf file as shown in the preceding figure. This is done by prefixing the directory assignment with one of the following:

  1. PHP_flag: to set Boolean directive
  2. PHP_value: to set the value of the specified directive
  3. PHP_admin_flag
  4. PHP_admin_value

For example, if we want to enable the use of short tags then we add the the following code snippet PHP_admin_flag short_open_tag On in the starting of httpd.conf file and restart our server if necessary.

We can modify the PHP configuration in our own PHP script file using the ini_set() function.


  1. ini_set('max_execution_time''60');  

Some of PHP configuration directives and their scopes are as follows:


More Information and directives can be seen in our PHP.ini file. We can changes their default value depending on our use.

If we want to see all the information regarding our PHP installation then we would write the following code in our PHP file:

  1. <?PHP  
  2.    PHPinfo();  
  3. ?>  

The PHP configuration environment provides an extensible nature for a project development by providing thousands of directives and their access level with information regarding them that can be found in the PHP.ini file or httpd.conf file.