Re: [new] PEAR::assertExtension()
| From: | Tomas V.V.Cox | Date: | Mon, 17 Jun 2002 13:45:42 +0000 |
| Subject: | Re: [new] PEAR::assertExtension() | ||
| References: | 1 2 3 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7117@lists.php.net to get a copy of this message | ||
"M@rms" wrote:
>
> Hi Tomas,
>
> >> I think you should test for both php_ex.suffix AND ex.suffix
> >> on every platform. I've seen linux modules being called
> >> php_whatever.so too.
> >>
>
> > Umm, what about this version:
>
> And this one ?
>
> function assertExtension($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;
> }
>
I've commited that format, it consumes a little more resources but we
love code readability no? :-)
For those who are not suscribed to the real true list pear-cvs, the log:
Modified files:
/php4/pear PEAR.php
Log:
Added PEAR::loadExtension($ext) - OS independant PHP extension load
# PEAR developers, please use this function if you need to check or
# load an extension.
Tomas V.V.Cox