開啟ci架構的源碼不難發現,在ci的核心input類中有這樣一個函數:
複製代碼 代碼如下:
function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.');
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE)
{
$str = $this->uni->clean_string($str);
}
return $str;
}
這是進行過濾的,所以拋出錯誤
我們在application的core中對這個方法進行重寫即可
命名一個為MY_Input.php(首碼MY_可以在config.php中自訂),然後將下面代碼加入即可
複製代碼 代碼如下:
class AI_Input extends CI_Input {
//建構函式
function __construct(){
parent::__construct();
}
function _clean_input_keys($str)
{
if(preg_match("/^,_[a-z0-9:_\/-]+$/",$str)){
$str = preg_replace("/,_/","",$str);
}
if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
{
exit('Disallowed Key Characters.'.$str);
}
return $str;
}
}
http://www.bkjia.com/PHPjc/756990.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/756990.htmlTechArticle開啟ci架構的源碼不難發現,在ci的核心input類中有這樣一個函數: 複製代碼 代碼如下: function _clean_input_keys($str) { if ( ! preg_match("/^[a-z0-9:_\/...