动态加载 PHP 扩展

By Symphony - Last updated: Wednesday, March 26, 2008 - Save & Share - Leave a Comment

<?php
if (!extension_loaded('gd')) {    // 如果没有加载 gd 库
if (!
dl('gd.so')) {    // 那么就动态加载
exit;
}
}
?>

关于使用 dl() 要注意的(以下内容摘自 php 手册):

注意: dl() is not supported
in multithreaded Web servers. Use the extensions statement in your
php.ini when operating under such an environment. However, the
CGI and CLI build are not affected !

注意: As of PHP 5, the dl() function is deprecated in every SAPI
except CLI. Use Extension
Loading Directives
method instead.

注意: Since PHP 6 this function is disabled in all SAPIs, except CLI,
CGI and embed.

注意: dl() is case sensitive on Unix platforms.

注意: 本函数在安全模式下被禁用。

Posted in Uncategorized • Tags: Top Of Page

Write a comment