【问题标题】:getting Error "undefined function mcrypt_create_iv()" in php 7.2 In Codeigniter在 Codeigniter 中的 php 7.2 中出现错误“未定义的函数 mcrypt_create_iv()”
【发布时间】:2019-03-06 06:24:57
【问题描述】:

我遇到了错误

错误 - 2018-10-01 12:05:23 --> 严重性:错误 --> 异常:调用未定义函数 mcrypt_create_iv() /var/www/html/application/controllers/api.php 331

在 AWS EC2 ubuntu 16(Php 7.2、Nginx、codeigniter 3.1.9)上部署应用程序

【问题讨论】:

    标签: codeigniter-3 php-7.2


    【解决方案1】:

    mcrypt 已从 php7.2 中删除。不能在 PHP 7.2 中使用。我创建了新功能并添加了通用助手。

    if (!function_exists('mcrypt_create_iv')) {
        function mcrypt_create_iv($length) {
            return openssl_random_pseudo_bytes($length, NULL);
        }
    }
    

    可能对其他用户有帮助。

    【讨论】:

    【解决方案2】:

    安装 mcrypt

    sudo apt-get install php7.2-mcrypt
    sudo systemctl restart nginx.service
    

    【讨论】:

      【解决方案3】:

      这个 polyfill 对于 PHP 7.3 上的 mcrypt 向后兼容很有用:

      https://github.com/phpseclib/mcrypt_compat

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-10
        • 1970-01-01
        • 1970-01-01
        • 2018-03-30
        • 2013-09-15
        • 1970-01-01
        • 1970-01-01
        • 2018-01-31
        相关资源
        最近更新 更多