note 88566 added to function.dl
| From: | shaunspiller at spammenot-gmail dot com | Date: | Thu, 29 Jan 2009 08:34:18 +0000 |
| Subject: | note 88566 added to function.dl | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149935@lists.php.net to get a copy of this message | ||
dl is awkward because the filename format is OS-dependent and because it can complain if the
extension is already loaded. This wrapper function fixes that:
<?php
function load_lib($n, $f = null) {
return extension_loaded($n) or dl(((PHP_SHLIB_SUFFIX === 'dll') ? 'php_' :
'') . ($f ? $f : $n) . '.' . PHP_SHLIB_SUFFIX);
}
?>
Examples:
<?php
// ensure we have SSL and MySQL support
load_lib('openssl');
load_lib('mysql');
// a rare few extensions have a different filename to their extension name, such as the image (gd)
library, so we specify them like this:
load_lib('gd', 'gd2');
?>
----
Server IP: 212.108.64.191
Probable Submitter: 89.100.60.13
----
Manual Page -- http://www.php.net/manual/en/function.dl.php
Edit -- https://master.php.net/note/edit/88566
Del: integrated -- https://master.php.net/note/delete/88566/integrated
Del: useless -- https://master.php.net/note/delete/88566/useless
Del: bad code -- https://master.php.net/note/delete/88566/bad+code
Del: spam -- https://master.php.net/note/delete/88566/spam
Del: non-english -- https://master.php.net/note/delete/88566/non-english
Del: in docs -- https://master.php.net/note/delete/88566/in+docs
Del: other reasons-- https://master.php.net/note/delete/88566
Reject -- https://master.php.net/note/reject/88566
Search -- https://master.php.net/manage/user-notes.php