diff options
author | Tomas V.V.Cox <cox@php.net> | 2002-06-17 13:39:29 +0000 |
---|---|---|
committer | Tomas V.V.Cox <cox@php.net> | 2002-06-17 13:39:29 +0000 |
commit | 87ddd960276487a9479f49c4f92477b5ef5a7b08 (patch) | |
tree | 9a1676f20143e8fd0a011ff425f92213ab4ad719 /pear/PEAR.php | |
parent | 9e67012d741d61ff088afee2f792b4512b90dc1f (diff) | |
download | php-git-87ddd960276487a9479f49c4f92477b5ef5a7b08.tar.gz |
Added PEAR::loadExtension($ext) - OS independant PHP extension load
# PEAR developers, please use this function if you need to check or
# load an extension.
Diffstat (limited to 'pear/PEAR.php')
-rw-r--r-- | pear/PEAR.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/pear/PEAR.php b/pear/PEAR.php index 9ed6fdc91d..f58a16b955 100644 --- a/pear/PEAR.php +++ b/pear/PEAR.php @@ -567,6 +567,35 @@ class PEAR } // }}} + // {{{ 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; + } + + // }}} } // {{{ _PEAR_call_destructors() |