PHP Manual
Prev | Chapter 4. Configuration | Next

# How to change configuration settings

## Running `PHP` as Apache module

When using PHP as an Apache module, you can also change the configuration settings using directives in Apache configuration files (e.g. `httpd.conf`) and `.htaccess` files (You will need "AllowOverride Options" or "AllowOverride All" privileges)

With PHP 3.0, there are Apache directives that correspond to each configuration setting in the `php3.ini` name, except the name is prefixed by "php3_".

With PHP 4.0, there are several Apache directives that allow you to change the PHP configuration from within the Apache configuration file itself.

php_value `name` `value`

  This sets the value of the specified variable.

php_flag `name` `on|off`

  This is used to set a Boolean configuration option.

php_admin_value `name` `value`

  This sets the value of the specified variable. "Admin" configuration settings can only be set from within the main Apache configuration files, and not from `.htaccess` files.

php_admin_flag `name` `on|off`

  This is used to set a Boolean configuration option.

Example 4-2. Apache configuration example
    <IfModule mod_php4.c>
      php_value include_path ".:/usr/local/lib/php"
      php_admin_flag safe_mode on
    </IfModule>
    <IfModule mod_php3.c>
      php3_include_path ".:/usr/local/lib/php"
      php3_safe_mode on
    </IfModule>

> Note: PHP constants do not exist outside of PHP. For example, in `httpd.conf` do not use PHP constants such as `E_ALL` or `E_NOTICE` to set the error_reporting directive as they will have no meaning and will evaluate to 0. Use the associated bitmask values instead. These constants can be used in `php.ini`

## Other interfaces to `PHP`

Regardless of the interface to `PHP` you can change certain values at runtime of your scripts through ini_set(). The following table provides an overview at which level a directive can be set/changed.

Table 4-1. Definition of PHP_INI_* constants

Constant | Value | Meaning
--- | --- | ---
PHP_INI_USER | 1 | Entry can be set in user scripts
PHP_INI_PERDIR | 2 | Entry can be set in `.htaccess` and VHost directives in httpd.conf.
PHP_INI_SYSTEM | 4 | Entry can be set in `php.ini` or `httpd.conf` (but not in VHost blocks in httpd.conf).
PHP_INI_ALL | 7 | Entry can be set anywhere

You can view the settings of the configuration values in the output of phpinfo(). You can also access the values of individual configuration settings using ini_get() or get_cfg_var().

Prev | Home | Next
Configuration | Up | Configuration directives