【问题标题】:CodeIgniter still show error whenever i already set encryption_key in config file每当我在配置文件中设置了 encryption_key 时,CodeIgniter 仍然显示错误
【发布时间】:2016-06-26 16:04:06
【问题描述】:

我不知道我的错误在哪里,当我将 CI 2.2.x 升级到 3.0.x 时,我按照这里的说明https://www.codeigniter.com/userguide3/installation/upgrade_300.html,发生了一些错误。

遇到错误

为了使用加密类需要你设置一个 配置文件中的加密密钥。

根据许多建议,我必须在配置文件(application/config/config.php)中设置encryption_key 我这样更改

$config['encryption_key'] = 'My Secret Key';

但是,我仍然遇到同样的错误。

你有什么想法还是我犯了其他错误?

感谢您的帮助

【问题讨论】:

    标签: php codeigniter encryption compiler-errors


    【解决方案1】:

    CI 版本 3.0.x 对系统文件夹中的文件进行了一些更改。特别是对于我上面的情况,我找到了解决方案。

    请在 system/library/Encrypt.php 上查看此功能

    public function get_key($key = '')
    {
        if ($key === '')
        {
            if ($this->encryption_key !== '')
            {
                return $this->encryption_key;
            }
    
            $key = config_item('encryption_key');
    
            if ( ! strlen($key))
            {
                show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
            }
        }
    
        return md5($key);
    }
    

    上线

    $key = config_item('encryption_key');
    

    var $keynever 在配置文件 (application/config/config.php) 上返回您的加密密钥 尽管您已经输入了密钥字符串,但它只显示空字符串。 将该行更改为

    $CI =& get_instance();
    $key = $CI->config->item('encryption_key');
    

    而 var $key 将在配置文件 (application/config/config.php) 上显示您的密钥字符串

    谢谢

    【讨论】:

      猜你喜欢
      • 2012-05-03
      • 1970-01-01
      • 1970-01-01
      • 2016-03-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多