【问题标题】:CodeIgniter still show error whenever i already set encryption_key in config file每当我在配置文件中设置了 encryption_key 时,CodeIgniter 仍然显示错误
【发布时间】:2016-06-26 16:04:06
【问题描述】:
【问题讨论】:
标签:
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) 上显示您的密钥字符串
谢谢