Working with php.ini file Configuration

Whether you're novice or experienced PHP programmer, PHP.ini configuration is essential. It's an important configuration file that is used to customize behaviour of PHP at runtime. When PHP server starts up it looks for PHP.ini file first to load various values for settings.

The php.ini file is where you can make changes to your PHP settings. You can use the default settings for the server, change specific settings by editing the existing php.ini, or create a new text file and name it php.ini.

Here we are explaining the important settings in php.ini which you can set to configure your PHP setup.


This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30. When running PHP from the command line the default setting is 0.
max_execution_time = 30


By this, you can set the error reporting level. The parameter is either an integer representing a bit field, or named constants. PHP 5.3 or later, the default value is E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
error_reporting = E_ALL


When PHP displays or logs an error, it has the capability of formatting the error message as HTML for easier reading. This directive controls whether the error message is formatted as HTML or not.
html_errors = On


If enabled, the last error message will always be present in the variable $php_errormsg.
track_errors = On


If you’re using Apache, already set a document root for this server. Set this value here if using safe mode or if you want to enable PHP only on a portion of your site.
doc_root = ''


This settings determines whether or not PHP will recognize code between <? and ?> tags as PHP source which should be processed as such. It's recommended that you not use the short tag and instead to use the full <?php and ?> tag combination.
short_open_tag = Off


The temporary directory used for storing files when doing file upload. Must be writable by whatever user PHP is running as. If not specified PHP will use the system's default. Also if the directory specified here is not writable, PHP falls back to the system default temporary directory.
upload_tmp_dir = ''


This determines whether to allow HTTP file uploads or not. The default is On, you can also set it OFF.
file_uploads = On


It's available since PHP 4.3.0. You can customise this setting to set the maximum time in seconds a script is allowed to parse input data, like POST and GET. Timing begins at the moment PHP is invoked at the server and ends when execution begins.
max_input_time = 60


This feature is available since PHP 5.3.9 which determine how many GET/POST/COOKIE input variables may be accepted.
max_input_vars = 1000


This is an amazing setting available since PHP 5.3.4. The settings determine maximum number of files that can be uploaded via a single request. The default value for this setting is 20 but you increase maximum number.
max_file_uploads = 20


You can set maximum size of post data, the default value is 8MB but you can also increase it. This setting also affects file upload. To upload large files, this value must be larger than upload_max_filesize. If memory limit is enabled by your configure script, memory_limit also affects file uploading.
// default value 'post_max_size'
post_max_size = 8M


It's an important php.ini setting available since PHP 5.4.0 and enabled by default. Disabling this causes $_POST and $_FILES not to be populated. This can be useful to proxy requests or to process the POST data in a memory efficient fashion.
enable_post_data_reading = Off


This is an important setting for development which determines whether errors should be printed to the screen as part of the output or if they should be hidden from the user. It's useful in debugging configuration problems during development. But you leave this setting off on production servers.
display_errors = On


You can set your character encoding to "UTF-8" through this setting. It's a default character encoding since PHP 5.6.0.
default_charset = "utf-8"

You may like these posts