From: Tomas V.V.Cox Date: Mon, 17 Jun 2002 13:39:29 +0000 (+0000) Subject: Added PEAR::loadExtension($ext) - OS independant PHP extension load X-Git-Tag: php-4.3.0dev_zend2_alpha2~227 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87ddd960276487a9479f49c4f92477b5ef5a7b08;p=php Added PEAR::loadExtension($ext) - OS independant PHP extension load # PEAR developers, please use this function if you need to check or # load an extension. --- diff --git a/pear/PEAR.php b/pear/PEAR.php index 9ed6fdc91d..f58a16b955 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -566,6 +566,35 @@ class PEAR return true; } + // }}} + // {{{ assertExtension() + + /** + * OS independant PHP extension load + * + * @param string $ext The extension name + * @return bool Success or not on the dl() call + */ + function loadExtension($ext) + { + if (!extension_loaded($ext)) { + if (OS_WINDOWS) { + $suffix = '.dll'; + } elseif (PHP_OS == 'HP-UX') { + $suffix = '.sl'; + } elseif (PHP_OS == 'AIX') { + $suffix = '.a'; + } elseif (PHP_OS == 'OSX') { + $suffix = '.bundle'; + } else { + $suffix = '.so'; + } + $ext = strtolower($ext); + return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix); + } + return true; + } + // }}} }