PHP.nl

dl

dl

Loads a PHP extension at runtime

bool **dl** string $extension_filename

Loads the PHP extension given by the parameter . extension_filename

Use to test whether a given extension is already available or not. This works on both built-in extensions and dynamically loaded ones (either through php.ini or ). extension_loaded``dl

Waarschuwing: > This function is only available for the and embed s, and the when run from the command line.

extension_filename This parameter is the filename of the extension to load which also depends on your platform. For example, the extension (if compiled as a shared module, not the default!) would be called on Unix platforms whereas it is called on the Windows platform. onlysockets

The directory where the extension is loaded from depends on your platform:

Windows - If not explicitly set in the php.ini, the extension is loaded from by default.

   Unix - If not explicitly set in the php.ini, the default extension
   directory depends on
   
   Taking into account the above, the directory then defaults to
   ,
   e.g.
   
   or
   .
  - whether PHP has been built with            or not          `--enable-debug`
  • whether PHP has been built with ZTS (Zend Thread Safety) support or not
  • the current internal (Zend internal module API number, which is basically the date on which a major module API change happened, e.g. ) ZEND_MODULE_API_NO``20010901

<install-dir>/lib/php/extensions/ <debug-or-not>-<zts-or-not>-ZEND_MODULE_API_NO

return.success If the functionality of loading modules is not available or has been disabled (by setting off in php.ini) an is emitted and execution is stopped. If fails because the specified library couldn't be loaded, in addition to false an message is emitted. enable_dlE_ERROR``dl``E_WARNING

Voorbeeld: examples

<?php
// Example loading an extension based on OS
if (!extension_loaded('sqlite')) {
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        dl('php_sqlite.dll');
    } else {
        dl('sqlite.so');
    }
}

// Or using PHP_SHLIB_SUFFIX constant
if (!extension_loaded('sqlite')) {
    $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
    dl($prefix . 'sqlite.' . PHP_SHLIB_SUFFIX);
}
?>

Opmerking: > is case sensitive on Unix platforms. dl

Extension Loading Directivesextension_loaded