我在控制台上收到以下错误:
<p>Severity: 8192</p>
<p>Message: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead</p>
<p>Filename: core/Security.php</p>
<p>Line Number: 512</p>
它指的是核心/安全行 512 中的功能:
public function entity_decode($str, $charset='UTF-8'){
if (stristr($str, '&') === FALSE)
{
return $str;
}
$str = html_entity_decode($str, ENT_COMPAT, $charset);
$str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("''1"))', $str);
return preg_replace('~&#([0-9]{2,4})~e', 'chr(''1)', $str);
}
发生这种情况是因为我将大量 HTML(纯 HTML(插入数据库。
public function add($data){
$this->security->xss_clean($data);
$this->db->insert('covers', $data);
return $this->db->insert_id();
}
如果我删除该行$this->security->xss_clean($data);
它就可以完美运行。
但是一旦我在Firefox上测试它,它就会停止在Chrome上运行(v.32.0.1(。在Firefox中进行测试并收到错误后,如果我转到Chrome并再次测试,我在Chrome中也遇到了同样的问题。
编辑:即使出现此错误,即使$this->security->xss_clean($data);
行打开,信息也会存储在数据库中,但警告会显示在控制台中。
在
代码中使用error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
,这将抑制错误
已解决。
我去了Ellislab支持,他们告诉我该功能不再使用。https://support.ellislab.com/bugs/detail/20646/the-e-modifier-is-deprecated-use-preg_replace_callback-instead
我复制新core/Security.php
并粘贴到我的上面,它现在可以工作了。