刚刚开始接触php,别人给我个.so文件和 .h头文件,让我在php里面调用,我直接用 dl("*.so") 的时候总是提示“Fatal error: Call to undefined function dl() in ” ,搜了下,有的说php5.3里某些SAPI不能用dl了,如果不能用dl的话,有什么方法可以替代吗??php dl

解决方案 »

  1.   


    暂时没有替代的,如果你是VPS或者可以修改配置的服务器,直接开启那个模块。
    如果没有开启权限,用判断函数是否存在再执行// Example loading an extension based on OS
    if (!extension_loaded('sqlite') && function_exists('dl')) {
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            dl('php_sqlite.dll');
        } else {
            dl('sqlite.so');
        }
    }
      

  2.   

    看看php.ini
    enable_dl的值是不是为off。
      

  3.   

    给你.h文件干什么用?php扩展只能加载动态链接库.so或.dll。如果时.h文件的话,你要把它们和.c文件先编译成php扩展的动态库才能用
      

  4.   

    我也遇到了这个问题 :
    dl()是做什么用的
    在php.ini中添加extension=module.so 和dl是什么区别
    没有dl PHP模块加载不了???  
      

  5.   


    dl是动态加载扩展库的函数。也就是在php进程启动后,在你调用dl函数时才把那个扩展库加载进来。
    而写在php.ini中,php进程启动时就会将动态库加载进来。至于两种方法相比较的话。使用前者php启动时所占用内存会少一些。使用后者,安全性会差一些(代码兼容性也会差一些,很多虚拟空间的服务器默认都会关闭dl函数,因为会造成安全问题)。php如果开启了安全模式,dl函数是强制不可用的。虽然使用dl表面看起来更合理(按需加载)。但还是不建议使用这种方式。
      

  6.   

    5.3.0dl() is now disabled in some SAPI's due to stability issues. The only SAPI's that allow dl() are: CLI, CGI and Embed. Use the Extension Loading Directives instead.
      

  7.   

    vim myfile.php
    <?php
    # dl('hwrsa.so');   
    echo "test";
    echo confirm_hwrsa_complied("qwer1234");
    ?>浏览器键入:127.0.0.1/hwrsa.php
    如果没有 :刷新 只出现 test终端运行:# php hwrsa.php
    成功返回信息vim /var/log/httpd/error_log 刷新浏览器的日志不加dl
    PHP Fatel error:Call to undefined function confirm_mymodule_complied() in hwrsa.php on line 2php.ini配置:
    enable_dl=On
    extension_dir ="/usr/lib64/php/modules/"
    extension=mymodule.so请问这个是什么问题  有没有什么方法解决
      

  8.   

    php.ini配置:
    enable_dl=On
    extension_dir ="/usr/lib64/php/modules/"
    extension=mymodule.so
    这样可以,9楼说的对
      

  9.   

    enable_dl boolean
    This directive is really only useful in the Apache module version of PHP. You can turn dynamic loading of PHP extensions with dl() on and off per virtual server or per directory.The main reason for turning dynamic loading off is security. With dynamic loading, it's possible to ignore all open_basedir restrictions. The default is to allow dynamic loading, except when using safe mode. In safe mode, it's always impossible to use dl().
      

  10.   

    Fatal error: Uncaught exception 'com_exception' with message 'Failed to create COM object `CCBRSA.RSASig': 无效的语法 '我遇到同样的问题,建设银行B2C接口编程,不知是什么原因?