我不知道我的错误在哪里,当我将CI 2.2.x升级到3.0.x时,我按照这里的说明https://www.codeigniter.com/userguide3/installation/upgrade_300.html发生了错误。
遇到错误
要使用加密类,需要设置一个 配置文件中的加密密钥。
基于很多建议,我必须在配置文件中设置encryption_key(application / config / config.php)我就这样改变了
$config['encryption_key'] = 'My Secret Key';
但是,我仍然有同样的错误。
你有任何想法或我做过其他错误吗?
感谢您的帮助
答案 0 :(得分:0)
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 $key
永远不会在配置文件(application / config / config.php)上返回您的encryption_key
它只显示空字符串,尽管您已经输入了密钥字符串。
将该行更改为
$CI =& get_instance();
$key = $CI->config->item('encryption_key');
和var $key
将在配置文件(application / config / config.php)上显示您的密钥字符串
由于