28.10. Don't Load Extensions Dynamically

The dl function allows applications to dynamically load extensions into PHP, thereby adding functionality to the PHP engine. It is the runtime equivalent of extension=/path/to/extension.so in php.ini. However, using dl has many drawbacks over using php.ini. We strongly encourage you not use it.

Dynamically loading a library for each script execution is much slower than doing it once on server startup. You're actually getting hurt twice, because if you load it using the extension directive in php.ini, it gets loaded once for all of the Web server processes instead of being loaded for each process separately.

Due to the nature of memory management under UNIX, loading an extension once on server startup is ...

Get Core PHP Programming, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.