I was going through php.ini and I have found the following parameter enable_dl with a strange description:
This directive is really only useful in the Apache module version of PHP. You can turn dynamic loading of PHP extensions with dl() on and off per virtual server or per directory.
The main reason for turning dynamic loading off is security. With dynamic loading, it’s possible to ignore all open_basedir restrictions. The default is to allow dynamic loading, except when using safe mode. In safe mode, it’s always impossible to use dl().
I am running php on apache and I am curious how exactly this parameter can be useful for me. Above-mentioned description is not really clear to me, so I would be thankful if someone can elaborate it.
Advertisement
Answer
PHP modules (extensions) can only be loaded in the startup-phase of PHP. For example it is not possible to load them with .user.ini
files. The extension
directive for example is php.ini only.
This is a hint – historically .user.ini
files were not in core, but per-directory .htaccess settings for the SAPI for Apache mod_php.
To circumvent this restriction in the past, the dl()
function had been introduced to dynamically load extensions at run-time. However only if enabled, so the enable_dl
directive.
However support for dl
has been largely disabled in current PHP SAPIs, having it available only in CLI and Embed.
As you haven’t been said why you’re curious about dl()
the best answer I can give, is that it is useful for esoteric reasons only. Most likely it’s even useless with the SAPI you want to use it with (you have not shared the SAPI name, but I guess it’s not CLI nor Embed).