We now have a youtube channel. Subscribe!

PHP.INI File Configuration

PHP .INI File Configuration

Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we will be studying about how to configure the PHP.INI File.

The PHP configuration file, php.ini, is the final and most instant way to affect PHP's functionality. The php.ini file is read each time PHP is initialized. In other words, whenever httpd is restarted for the module version or with each script execution for the CGI version. If your change isn't showing up, do remember to stop and the restart httpd. If it still isn't showing up, use phpinfo() to check the path to php.ini.

The PHP configuration file is well commented and detailed. Keys are case sensitive, keyword values are not. Whitespace and lines beginning with semicolons are overlooked. Booleans can be represented by 1/0, Yes/No, On/Off, or True/False. The default values in php.ini-dist is going to result to a proper PHP installation that can be adjusted later.

In this tutorial, we are explaining the important settings in php.ini which you may need for your PHP Parser.


Short open tags look like this: <? ?>. This option must be set to Off if you want to use XML functions.


If this settings is set to On, then you probably compiled your PHP with the --enable-safe- mode flag. Safe mode is the most relevant to CGI use. See the explanation in the following section "CGI compile-time options".


This option is useful only when safe mode is on; it can also be set using the -with-exec-dir flag during the Unix build process. A PHP in safe mode only executes external binaries out of this directory. The default path is /usr/local/bin. This has nothing to do with serving up the normal PHP Web page.


This configuration option sets which environment variables users can change in safe mode. Default is only those variables prepended with "PHP_". If this option is empty, most values are alterable.


This configuration option sets which environment variables users can't change in safe mode.

disable_functions=[function1, function2...]

This option has the ability to disable some selected functions for security reasons. Formally, this necessitated hand-editing the C code from which PHP was made. Filesystem, system, and the network functions should probably be the first to go because allowing the capability to write files and alter the system over HTTP is never a safe idea.


The function set_time_limit() won't work when safe mode is on, so this is the main way in making a script to time out in safe mode. In Windows, you have to end based on maximum memory consumed rather than time. The Apache timeout setting can also be used to time out if you are making use of Apache, but that will apply to non-PHP files on the website too.

error_reporting=E_ALL & ~E_NOTICE

The default values of this option are E_ALL and ~E_NOTICE, all other errors except for the notices. Development servers should be set to at least the default; only the production servers should even consider a lesser value.


This setting allows you to make error messages different colors than other text, or what you have.


This setting issues a warning if the + operator is used with strings, as in a form value.


This setting replaces gpc_order. Both are now deprecated along with register_globals. This sets the order of the various variables: ENV, GET, POST, COOKIE, and SERVER. You can change this order around. The variables will be overwritten successively in the left-right order, with the right most one winning the hand every time. This means if you left the default setting and happened to use the same name for an environment, POST, and COOKIE variable, then the COOKIE variable will own that name at the end of the process.


This configuration settings allows you to decide whether you wish to register the EGPCS variables as global. This is no longer accepted, and as of PHP v4.2, this flag is set to Off by default. You can make use of superglobal arrays instead. All of the major code listings in this discussion makes use of the superglobal arrays.


This configuration setting has been GPC deprecated.


This configuration setting escapes quotes in incoming GET, POST, and COOKIE data. If you use various forms which possibly submit to themselves or other forms and display the form values, then you may need to set this directive to On or prepare to make use of the addslashes() function on string-type data.


This configuration setting escapes quotes in incoming database and text strings. Do remember that SQL adds slashes to both single quotes and apostrophes when its storing strings and does not strip them off when its returning them. If this setting is Off, then you will need to use stripslashes() when outputting any type of string information from SQL database. If magic_quotes_sybase is set to On, then this must be Off.


This configuration setting escapes single quotes in the incoming database and text strings with the Sybase-style single quotes rather than backlashes. If the setting "magic_quotes_runtime" is set to On, this must be Off.


If a path is specified here, PHP must automatically include() it at the start of every PHP program file. Include path restrictions do apply.


If a path is specified here, PHP must automatically include() it at the end of every PHP file, unless you escape by using the exit() function. Include path restrictions do apply.


If you set this value, you will only be permitted to include file from these directories. The include directory is generally under your document root; this is mandatory if you are running in safe mode.


If you are making use of Apache, you have already set a document root for this server in httpd.conf. Make sure to set this value here if you are using safe mode or if you want to enable PHP only on a portion of your site (for example, only in one subdirectory of your Web root).


Turn on this setting if you will upload files using PHP script.


Do not uncomment this line unless you understand the implications of HTTP uploads.


Except in rare occasions, you will not want to change this setting. So don't touch it.


This configuration setting controls what happens if a Website visitor clicks on the Web browser's Stop button. The default is On, which means that the script continues to run to completion or timeout. If the setting is changed to Off, then the script will abort. This setting only works in module mode, not CGI.


The default server host to use when connecting to the database server if no other host is specified.


The default user name to use when connecting to the database server if no other name is set out.


The default password to use when connecting to the database server if no other password is specified.

Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial guide, we are going to be discussing about the PHP Basic Syntax.

Feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain