By Richard Blum

The PHP server configuration file is named php.ini, but it can be located in several different areas. The locations that the PHP server checks are (in order):

  • The path set in the PHPIniDir directive in the Apache web server configuration file
  • The path set in a system environment variable named PHPRC
  • For Windows systems, the path set in the registry key named IniFilePath under the HKEY_LOCAL_MACHINE/Software/PHP registry hive
  • The folder where the PHP server executable file is stored
  • The default web server’s folder
  • The OS system folder, which for Windows is the c:\winnt folder, and for Linux and Mac the /usr/local/lib folder

The XAMPP install process places the php.ini file in the c:\xampp\apache\bin folder.

If you’re ever in doubt as to which php.ini configuration file the PHP server is using, run the phpinfo() function in a small PHP program. For your convenience, all the popular all-in-one packages provide a link to run the phpinfo() function from their main web pages. This image shows the output from the phpinfo() function in XAMPP running on a Windows system.

phpinfo() function
The phpinfo() function output.

The phpinfo() function displays the system values for each of the configuration file settings and if any were overridden by a local setting. Look for the Loaded Configuration File entry that shows the path to the active php.ini file to see where that file is located for your PHP server.

As you can imagine, there are lots of settings available in the php.ini configuration file. Here are some of the php.ini settings (and the default values set in XAMPP) that you may need to tweak on your PHP server:

  • date.timezone = Europe/Berlin: Defines the time zone of the PHP server. This must use a time zone value defined at http://php.net/manual/en/timezones.php.
  • display_errors = On: Defines whether PHP error messages appear on the web page. This feature is extremely handy for development work but should be disabled for production servers.
  • error_reporting = E_ALL & ~E_DEPRECATED: Sets the level of error reporting from the PHP server. PHP uses a complicated bit pattern to set which errors to display or not display. It uses labels to indicate the error level and Boolean bitwise operators to combine the levels — the tilde (~) indicates the NOT operator. The error levels are:
    • E_ERROR: Fatal run-time errors
    • E_WARNING: Run-time warnings that won’t halt the script
    • E_PARSE: Parsing syntax errors
    • E_NOTICE: Script encountered something that could be an error and effect the results
    • E_CORE_ERROR: Fatal error that prevents PHP from starting
    • E_CORE_WARNING: Non-fatal errors during startup
    • E_COMPILE_ERROR: Fatal error while compiling the PHP code
    • E_COMPILE_WARNING: Non-fatal errors during compile time
    • E_USER_ERROR: Fatal error message generated manually by your PHP code
    • E_USER_WARNING: Non-fatal error message generated manually by your PHP code
    • E_USER_NOTICE: Notice message generated manually by your PHP code
    • E_STRICT: PHP detected code that doesn’t follow the PHP strict rules
    • E_RECOVERABLE_ERROR: A fatal error that you can catch with a try-catch block
    • E_DEPRECATED: The PHP parser detected code that will no longer be supported
    • E_USER_DEPRECATED: A deprecation error generated manually by your PHP code
    • E_ALL: All errors and warnings except E_STRICT
  • variables_order = "GPCS": The order in which PHP populates the data from the HTTP session (G = GET, P = POST, C = Cookies, and S = System variables)
  • short_open_tag = Off: Determines if you can use the <? tag to identify PHP code in your HTML documents
  • max_execution_time = 30: Sets a time limit (in seconds) for a PHP program to run before the PHP server kills it (This is useful for stopping programs stuck in a loop!)
  • memory_limit = 128M: Sets a limit on how much memory on the physical server the PHP server can allocate (This also helps prevent runaway programs from taking down the entire web server!)