]> granicus.if.org Git - php/commitdiff
Added PEAR::loadExtension($ext) - OS independant PHP extension load
authorTomas V.V.Cox <cox@php.net>
Mon, 17 Jun 2002 13:39:29 +0000 (13:39 +0000)
committerTomas V.V.Cox <cox@php.net>
Mon, 17 Jun 2002 13:39:29 +0000 (13:39 +0000)
# PEAR developers, please use this function if you need to check or
# load an extension.

pear/PEAR.php

index 9ed6fdc91d7b226086c98a6e61ca24d86db6c4bf..f58a16b9552d5b8e3615975216c6892bc9ff042e 100644 (file)
@@ -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;
+    }
+
     // }}}
 }