Skip to content

PHP.ini Configuration

Published: at 04:19 AM

PHP.ini Configuration

The php.ini file is the initialization file for PHP and is responsible for configuring many aspects of PHP’s behavior. PHP searches for and loads this configuration file from various locations.

Search Order for php.ini

PHP attempts to find and load the php.ini configuration file from the following locations:

  1. SAPI module specific location
  2. The PHPRC environment variable (as of PHP 5.2.0)
  3. Predefined registry keys on Windows (as of PHP 5.2.0)
  4. Current working directory (except for CLI)
  5. The web server’s directory (for SAPI modules), or the directory of PHP (otherwise in Windows)
  6. The directory from the --with-config-file-path compile-time option, or the Windows directory (C:\windows or C:\winnt)

For more information, see the PHP documentation: PHP Configuration File.

Syntax of php.ini

The syntax in the php.ini file is simple:

Currently, [PATH=] and [HOST=] sections only work under CGI/FastCGI environments. For more details, visit: INI Sections.

Directive Syntax

Directives in php.ini are specified using the following syntax:

directive = value

Boolean Flags

About php.ini Files

PHP comes packaged with two php.ini files:

  1. php.ini-production: Contains settings optimized for security, performance, and best practices for production environments. However, these settings may break compatibility with older or less secure applications. It’s recommended to use php.ini-production in production and testing environments.
  2. php.ini-development: Similar to php.ini-production, but with more verbose error reporting. This version should be used only in development environments to avoid leaking sensitive information to users.

Quick Reference for Production vs Development

Below are key differences between php.ini-production and php.ini-development regarding PHP’s default behavior. These settings are designed to help optimize PHP for either production or development environments.

SettingDefault ValueDevelopment ValueProduction Value
display_errorsOnOnOff
display_startup_errorsOffOnOff
error_reportingE_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATEDE_ALLE_ALL & ~E_DEPRECATED & ~E_STRICT
html_errorsOnOnOn
log_errorsOffOnOn
max_input_time-1 (Unlimited)6060
output_bufferingOff40964096
register_argc_argvOnOffOff
request_orderNone”GP""GP”
session.gc_divisor10010001000
session.hash_bits_per_character455
short_open_tagOnOffOff
track_errorsOffOnOff
url_rewriter.tags”a=href, area=href, frame=src, form=""a=href, area=href, frame=src, input=src, form=fakeentry""a=href, area=href, frame=src, input=src, form=fakeentry”
variables_order”EGPCS""GPCS""GPCS”

php.ini Options

Language Options

Additional Security Features

For more detailed settings and configurations, refer to the PHP Documentation.


Previous Post
.htaccess Configuration
Next Post
Setting Up Pingman on Cron