The PHP configuration file, php.ini, is the last and most direct step that affects PHP's functionality. This php.ini file is read every time PHP is initialized, in other words, whenever httpd is restarted for the Module Version or with each Script execution for CGI version. If your changes don't show up, remember to stop and restart httpd. If still not showing, use phpinfo() to check the path to php.ini.
The configuration file should be clearly and carefully noted. Keys are case sensitive, keyword values are not; Whitespaces, lines beginning with semicolons are ignored. Boolean values can be represented by 1/0, Yes / No, On / Off or True / False.
The following section explains important settings in the php.ini required for PHP Parser.
short_open_tag = Off
Short open tags look like: <? ?>. This option must be set to Off if you want to use XML functions.
safe_mode = Off
If set to On, you can compile PHP with the --enable-safe-mode flag. Safe mode is best suited to use CGI. You should follow the CGI compile-time option explanation.
safe_mode_exec_dir = [DIR]
This option is only appropriate if safe mode is On; it can also be set with the --with-exec-dir flag during the Unix build process. PHP in safe mode only executes Binary outside of this directory. The default value is /usr/local/bin.
safe_mode_allowed_env_vars = [PHP_]
This option sets which environment variables the user can change in Safe mode. The default value is these variables appended with "PHP_". If this directive is empty, most variables are mutable.
safe_mode_protected_env_vars = [LD_LIBRARY_PATH]
This option sets which environment variables users cannot change in Safe mode, even if safe_mode_allowed_env_vars is set arbitrarily.
disable_functions = [function1, function2 ...]
An interesting addition to PHP configuration and permanent in PHP is the ability to disable selected functions for safety reasons. Previously, this needed to be manually edited by the C code from which the PHP was generated. The Filesystem, system and Network functions should be operational first, because it allows the ability to write files and modify the System over HTTP is never a safe initiative.
max_execution_time = 30
The set_time_limit() function does not work in Safe mode, so this is the main way to create a timeout in safe mode.
error_reporting = E_ALL & ~ E_NOTICE
The default value is E_ALL & ~ E_NOTICE, all errors except Notice. Server should be set to at least one default value.
error_prepend_string = [" "]
With its backend, error_append_string, this setting allows you to generate Error Messages of different colors.
warn_plus_overloading = Off
This setting reports a Warning if the + operator is used with strings, when in a form value.
variables_order = EGPCS
This configuration setting replaces gpc_order. Now, both are old with register_globals. It sets the order of the different variables: Environment, GET, POST, COOKIE, and SERVER. You can change this order. Variables will be successfully overwritten from left to right. It hasn't really been used much.
register_globals = Off
This setting allows you to decide whether or not you want to register EGPCS variables as global. It is now old, and as in PHP it is set to Off by default. Use superglobal arrays instead. All the major code listings in this series use the superglobal array.
gpc_order = GPC
This setting is outdated.
magic_quotes_gpc = On
This setting escapes quotes in the incoming GET / POST / COOKIE data. If you use multiple forms that can submit to themselves or another form and display form values, you may need to set this directive to On or prepare to use addslashes() on string-type data.
magic_quotes_runtime = Off
This setting escapes citations in incoming Database and Text strings. Remember, SQL adds slashes in single quotes and apostrophes when storing strings and doesn't omit them on return. If the setting is Off, you will need to use stripslashes() when it returns any string data type from an SQL Database. If magic_quotes_sybase is set to On, this should be Off.
magic_quotes_sybase = Off
This setting escapes citations in incoming Database and Text strings with Sybase-style single quotes instead of backslashes. If magic_quotes_runtime is set to On, this setting should be Off.
auto-prepend-file = [path/to/file]
If a path is specified here, PHP must automatically wrap it at the beginning of each PHP file. Included file restrictions apply.
auto-append-file = [path/to/file]
If a path is specified here, PHP must automatically wrap it at the end of every PHP file, unless you exit with the exit () function. Included file restrictions apply.
include_path = [DIR]
If you set this value, you will only be allowed to include or request files from these directories. In general, this include folder is under Document Root; This is required. If you are running in Safe Mode, set it to. to include files from the same directory your script is in. Multiple directories are separated by a colon:.: / Usr/local/apache/htdocs:/usr/local/lib.
doc_root = [DIR]
If you are using Apache, you have set up a Document Root for this Server or Virtual Host in httpd.conf. Set this value here if you are using Safe Mode or if you want to enable PHP only on a portion of your site (eg only in a sub-directory of Web Root).
file_uploads = [on/off]
Is on if you are going to upload files using PHP scripts.
upload_tmp_dir = [DIR]
Don't uncomment this line unless you understand what HTTP uploads mean.
session.save-handler = files
You rarely want to change this setting, so don't touch it.
ignore_user_abort = [On / Off]
This setting controls what happens if a site visitor clicks the browser's Stop button. The default is On, which means the script continues to run for completion or timeout. If the setting is changed to Off, the script will stop midway. This setting only works in Module Mode, not CGI.
mysql.default_host = hostname
The default Server Host is used when connecting to Database Server if no other host is specified.
mysql.default_user = username
The default username to use when connecting to the Database Server if no other name is specified.
mysql.default_password = password
Default password to use when connecting to Database Server if no other password is specified.