Home  >  Article  >  Backend Development  >  CodeIgniter framework prompts the solution to Disallowed Key Characters_PHP tutorial

CodeIgniter framework prompts the solution to Disallowed Key Characters_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:32:02738browse

Opening the source code of the ci framework, it is not difficult to find that there is such a function in the core input class of ci:

Copy the code The code is as follows:

function _clean_input_keys($str)
{
if ( ! preg_match("/^[a-z0-9:_/-]+$/i", $str) )
{
exit('Disallowed Key Characters.');
}

{ $ Str = $ this- & gt; UNI-& GT; Clean_string ($ str) (🎜>}


🎜>}
, so an error is thrown

We can rewrite this method in the core of the application
Name it MY_Input.php (the prefix MY_ can be customized in config.php), and then add the following code

Copy code

The code is as follows:

class AI_Input extends CI_Input { //Constructor
function __construct( ){
parent ::__construct();
}

function _clean_input_keys($str)
{
if(preg_match("/^,_[a-z0-9 :_/-]+$/",$str)){
                $str = preg_replace("/,_/","",$str); preg_match("/^[a-z0-9:_/-]+$/i", $str))
                                                                                                                                                     
       return $str;
    }
}






http://www.bkjia.com/PHPjc/756990.html

www.bkjia.com

true
http: //www.bkjia.com/PHPjc/756990.html

TechArticle

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn