The file php.ini is used for setting php directive value. It changes the php’s behaviors.
What is php.ini file?
PHP will dump php.ini file as php.ini.dist and php.ini.recommended. In the absence of php.ini file php can use the default built-in configuration value. Rename php.ini.recommended file to php.ini and place it on the right place.
On window php.ini can be at the following place:
* PHPIniDir directive (Apache 2 module only)
* The PHPRC environment variable
* Directory of PHP (for CLI), or the web server's directory (for
* Windows directory (C:\windows or C:\winnt)
On window better store the renamed file “php.ini” to php directory itself and set the PHPRC environment variable.
On Linux it can be at the following place:
It is generally found at /etc folder.
You can run the phpinfo() function and there you can find the php.ini path. You can use locate command on linux/unix also for finding the file.
Syntax of php.ini file is simple:
Directive are specified using following syntax-
Directive = value
You can comment a line by semicolon (;).
Directive names are case-sensitive.
The value can be a string, a number, a PHP constant (e.g. E_ALL or M_PI), one of the INI constants (On, Off, True, False, Yes, No and None) or an expression (e.g. E_ALL & ~E_NOTICE), or a quoted string ("foo").
An empty string can be denoted by simply not writing anything after the equal sign, or by using the None keyword.
Some important php.ini config settings:
The root of the PHP pages, used only if nonempty.
doc_root = C:\Program Files\Apache Group\Apache2\htdocs
Maximum execution time of each script, in seconds
max_execution_time = 30
Maximum amount of time each script may spend parsing request data
max_input_time = 60
Maximum amount of memory a script may consume (8MB)
memory_limit = 8M
Whether to allow HTTP file uploads.
file_uploads = On
Maximum allowed size for uploaded files.
upload_max_filesize = 2M
Set Maximum size of POST data that PHP will accept.
post_max_size = 8M
Include path is used for searching file specified by include/require/include_once/require_once. If file is not found on the path provided, then it will look at "include_path" location set in php.ini.
include_path = "path to include folder"
Global variables are no longer registered for input data (POST, GET, cookies, environment and other server variables). So, for example, you cannot use $lang for $_GET[‘lang’].
register_globals = Off
This directive describes the order in which PHP registers GET, POST, Cookie, Environment and Built-in variables (G, P, C, E & S respectively, often referred to as EGPCS or GPC). Variable registration is done from left to right; newer values override older values.
variables_order = "GPCS"
Allow the <? Tag also. Otherwise you can use <?php and <script> tags only.
short_open_tag = On
Input data is no longer escaped with slashes
magic_quotes_gpc = Off
Set Error reporting levels. Set not to display errors.
Print out errors as a part of the output.
display_errors = Off
Disable the inclusion of HTML tags in error messages.
html_errors = Off
Log scripts errors to system log or other configured places.
log_errors = On
Treat url as file.
allow_url_fopen = On
Store the last error/warning message in $php_errormsg.
track_errors = Off
Safe Mode does a UID compare check when opening files
safe_mode = Off
safe_mode_gid = Off
zlib.output_compression = Off
implicit_flush = Off
It is a Directory in which the loadable extensions (modules) reside.
extension_dir = "./"