php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #17798 OS Independat Extension Loading dl()
Submitted: 2002-06-17 07:07 UTC Modified: 2002-06-17 07:33 UTC
From: cox at idecnet dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.2.1 OS: All
Private report: No CVE-ID: None
 [2002-06-17 07:07 UTC] cox at idecnet dot 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-17 07:17 UTC] 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:25 UTC] cox at idecnet dot 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:33 UTC] markonen@php.net
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.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jun 16 18:00:02 2026 UTC