mina
mina

Reputation: 141

What is the difference between extensions and php.ini directives?

What is the difference between extensions and php.ini directives?

For example in php.ini directives I saw mbstring.http_input as option, and I also saw it in extensions as multibyte string extension.

Upvotes: 4

Views: 164

Answers (2)

Dekel
Dekel

Reputation: 62536

The directives are general configurations options - settings.
Some you can change at runtime (using the ini_set function), some you can only change using the configuration file (php.ini, or .htaccess).

Extensions are binary-compiled libraries which enable specific functions to be used in your PHP code. They are written in C and loaded dynamically using

extension=ext.dll/ext.so ; (based on your OS)

Some extensions provides/require also configuration options, and those can be handled/changed exactly the same way any other directive works.

For example, the xdebug extension gives us the ability to control the output of the var_dump function using

xdebug.var_display_max_children
xdebug.var_display_max_data
(and more)

These directives control/affect the extension that was loaded dynamically.

Upvotes: 2

CodeCaster
CodeCaster

Reputation: 151588

An extension, as its name implies, extends the features of the language and runtime. It can add new functions and types to the global scope (for example the mysqli_ functions from the MySQLi extensions) or change existing implementations so they do things faster or differently.

But the functionality provided by an extension hardly ever fits all scenarios. Enter the settings file: here you can configure parameters known to the extension, so the extension can alter its behavior based on your configuration. See for example the MySQLi Runtime Configuration page.

Upvotes: 0

Related Questions