It is possible to load extension libraries at runtime, if they are not compiled in, using the dl() function.
dl() function expects as a parameter the name of the file containing the library. IN UNIX, it will be filenames ending in .so; and in Windows, filenmames will end in .dll.
An example of a call to dl() is
dl(“php_ftp.dll”);
The above code will dynamically load the FTP extension (on a Windows machine).
You need not specify the directory where the file lives: Instead, you should configure this in the php.ini file. A directive called extension_dir will specify the directory where PHP will
look for libraries to dynamically load.
If you find you are having trouble dynamically loading extensions, then check your php.ini file for the enable_dl directive. If it’s off, you won’t be able to dynamically load extensions.
Generally if the machine you work on is not your own, this might be disabled for security reasons. You also won’t be able to use dl() if PHP is running in safe mode.
- Kiran's blog
- 1124 reads













Post new comment