[new] PEAR::assertExtension()

From: Date: Mon, 17 Jun 2002 11:10:20 +0000
Subject: [new] PEAR::assertExtension()
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-7092@lists.php.net to get a copy of this message
What do you think on adding a new function to PEAR.php assertExtension() which will: 1) Load an extension if is not loaded already 2) Return bool 3) OS independant The code: + // {{{ assertExtension() + + function assertExtension($ext) + { + if (!extension_loaded($ext)) { + if (OS_WINDOWS) { + return @dl("php_$ext.dll"); + } elseif (PHP_OS == 'HP-UX') { + return @dl("$ext.sl"); + } elseif (PHP_OS == 'AIX') { + return @dl("$ext.a"); + } else { + return @dl("$ext.so"); + } + } + return true; + } + + // }}} You know the bounch of places where such check are done, equally to the number of places where that check is wrong made :-) Of course the really Good Thing would be to change the dl() behaviour to take care automatically on it (http://bugs.php.net/bug.php?id=17798) Tomas V.V.Cox

« previous php.pear.dev (#7092) next »