php.ini - PHP Runtime Configuration

This section describes the PHP runtime configuration file, php.ini.

PHP runtime behavior can be controlled by a runtime configuration file called php.ini in the \php folder. The PHP installation package provides 2 versions of php.ini:

php.ini-development   - More secure and better performance
php.ini-production    - More verbose in error messages

Since we are running PHP on a local machine to learn the PHP language, we should use the php.ini-development version. So let's copy php.ini-development to php.ini:

>copy \php\php.ini-development \php\php.ini
        1 file(s) copied.

>type \php\php.ini | more
[PHP]

;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible
; for configuring many of the aspects of PHP's behavior.
; ...

; Name for user-defined php.ini files. Default is ".user.ini"
;user_ini.filename = ".user.ini"

; To disable this feature set this option to empty value
;user_ini.filename =

; TTL for user-defined php.ini files (time-to-live) in seconds.
; Default is 300 seconds (5 minutes)
;user_ini.cache_ttl = 300

; Enable the PHP scripting language engine under Apache.
engine = On

...

As you can see the php.ini file is very easy to use. The ";" character at the beginning of the line indicates a comment line. Configuration settings are provided in the format of "name = value". The default version of php.ini comes with lots of comments to help you understand what is the meaning of each setting.

For example, if I want to set a default timezone in runtime environment, I can edit php.ini and change the "date.timezone" setting:

>edit \php\php.ini

; Defines the default timezone used by the date functions
date.timezone = Europe/Paris

Now the PHP engine will be running with Europe/Paris as the default timezone.

Table of Contents

 About This Book

Introduction and Installation of PHP

 What Is PHP

 Downloading and Installing PHP 7.3 for Windows

 "php -help" - Command Line Options

 "php -m" - Built-in Modules

 "php -i" - PHP Engine Information

php.ini - PHP Runtime Configuration

 Hello.php - My First PHP Script

 "php -a" - PHP Interactive Shell

 Downloading and Installing PHP Documentation

 Managing PHP Engine and Modules on macOS

 Managing PHP Engine and Modules on CentOS

 cURL Module - Client for URL

 DOM Module - Parsing HTML Documents

 GD Module - Manipulating Images and Pictures

 MySQLi Module - Accessing MySQL Server

 OpenSSL Module - Cryptography and SSL/TLS Toolkit

 PCRE Module - Perl Compatible Regular Expressions

 SOAP Module - Creating and Calling Web Services

 SOAP Module - Server Functions and Examples

 Zip Module - Managing ZIP Archive Files

 References

 Full Version in PDF/EPUB