note 99606 added to function.dl

From: Date: Thu, 26 Aug 2010 10:59:51 +0000
Subject: note 99606 added to function.dl
Groups: php.notes 
Request: Send a blank email to php-notes+get-172079@lists.php.net to get a copy of this message
A class to dl - regarding shaunspiller's way to solve different extension formats class Class_to_dl { private function __construct() { $ext = func_get_arg(); $ext_rgx = '/^(php_)?+(\w++)(\.(?(1)(dll)|(so)))?$/i'; if (preg_match($ext_rgx, $ext, $m) && !extension_loaded($m[2])) { $ext = preg_replace($ext_rgx, PHP_SHLIB_SUFFIX == 'dll' ? 'php_\\2.' : '\\2.', $ext).PHP_SHLIB_SUFFIX; try { if (!($ext = self::isExtension($ext) && dl($ext))) throw new Exception('--!??!--'); } catch (Exception $e) { die($e->__toString()); } } } private static function isExtension() { static $ext_dir; if (is_null($ext_dir)) $ext_dir = scandir(ini_get('extension_dir')); return ($key = array_search(strtolower(func_get_arg(0))), array_map('strtolower', $ext_dir)) ? $ext_dir[$key] : $key; } public static function setExtension() { if (!(function_exists('dl') && ini_get('enable_dl'))) throw new Exception('--!??!--'); for ($i = 0, $n = func_num_args(); $i < $n; ++i) new self(func_get_arg($i)); } } Class_to_dl::setExtension($ext_1 [, $ext_2 [,...]]); where $ext_i can be given in various formats, for example Class_to_dl::setExtension('php_ext_1', 'php_ext_2.dll', 'ext_3', 'ext_4.so'); ---- Server IP: 193.198.184.18 Probable Submitter: 93.143.3.233 ---- Manual Page -- http://www.php.net/manual/en/function.dl.php Edit -- https://master.php.net/note/edit/99606 Del: integrated -- https://master.php.net/note/delete/99606/integrated Del: useless -- https://master.php.net/note/delete/99606/useless Del: bad code -- https://master.php.net/note/delete/99606/bad+code Del: spam -- https://master.php.net/note/delete/99606/spam Del: non-english -- https://master.php.net/note/delete/99606/non-english Del: in docs -- https://master.php.net/note/delete/99606/in+docs Del: other reasons-- https://master.php.net/note/delete/99606 Reject -- https://master.php.net/note/reject/99606 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172079) next »