Bug #17798 Updated: OS Independat Extension Loading dl()
| From: | markonen@php.net | Date: | Mon, 17 Jun 2002 11:33:52 +0000 |
| Subject: | Bug #17798 Updated: OS Independat Extension Loading dl() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-10846@lists.php.net to get a copy of this message | ||
ID: 17798
Updated by: markonen@php.net
Reported By: cox@idecnet.com
Status: Closed
Bug Type: Feature/Change Request
Operating System: All
PHP Version: 4.2.1
New Comment:
In a word, yes. We don't have control over how people name
their PHP extensions. The Mac OS X version is a good
example: the PHP extensions on this platform will have the
suffix ".bundle", while PHP_SHLIB_SUFFIX will contain
".dylib".
There are a ton of problems with dl() anyway, so if you
wish to write portable code, just instruct your users to
edit php.ini to load extensions where appropriate instead
of relying on that old hack.
Previous Comments:
------------------------------------------------------------------------
[2002-06-17 07:25:16] cox@idecnet.com
It will work for Windows too? AFAIK extensions there are in the form
"php_<ext>.dll". Anyways I found the PHP_SHLIB_SUFFIX "hack" still
obscure and ugly. Is so difficult to do it automatically?
Tomas V.V.Cox
------------------------------------------------------------------------
[2002-06-17 07:17:12] edink@php.net
Stig already added constant PHP_SHLIB_SUFFIX so you can do something
like (in PHP >= 4.3.0):
dl($ext.'.'.PHP_SHLIB_SUFFIX);
------------------------------------------------------------------------
[2002-06-17 07:07:47] cox@idecnet.com
Change the actual behaviour of dl() to be OS independant, avoiding the
actual workarround:
+ 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;
-- Tomas V.V.Cox
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17798&edit=1