Home > Article > Backend Development > Extension loading mechanism for PHP functions
PHP extension loading is loaded directly through the php.ini configuration file or code, respectively: 1. Add the extension=module_name.so line to the php.ini configuration file; 2. Dynamically load using the dl("module_name.so") function Extension.
PHP function extension loading mechanism
PHP extension is a dynamic link library (DLL) used to extend the functions of PHP . It can be loaded in the following two ways:
1. php.ini configuration file
The extension can be loaded in the php.ini
configuration file Add the following line to load:
extension=module_name.so
For example, to load the gd
extension:
extension=gd.so
2. Directly through code
Extensions can also be loaded through code at runtime:
dl("module_name.so");
For example, to load the imagick
extension:
dl("imagick.so");
Practical case
Suppose we want to load the intl
extension to handle internationalization. We can do it in the following way:
dl("intl.so");
If the loading is successful, we can verify it by the following code:
var_dump(extension_loaded('intl')); // true
Note:
.dll
on Windows and .so
on Linux. The above is the detailed content of Extension loading mechanism for PHP functions. For more information, please follow other related articles on the PHP Chinese website!