Home  >  Article  >  Backend Development  >  Methods and code examples for safe filtering of special characters in PHP

Methods and code examples for safe filtering of special characters in PHP

WBOY
WBOYOriginal
2016-07-25 09:13:351315browse



字Php The method and code example of the special character's security filtering
    & function checkhacks ($ Checkinfo, $ action) {// action 0 directly exit and prompts, replace the dangerous Chinese

  1.                                                                                                       ;$i
    (IF (STRPOS ($ Checkinfo, $ Badwords [$ i])! = False) {


  2. IF ($ Action == "0") {

  3. Echo "system detects prohibited Special characters: ". $ Badwords [$ i];

  4. exit;

  5. Break;}} elseif ($ action ==" 1 ") {

  6. $ Checkinfo = Str_replace ($ badwords [$ i]," "" "" "" "" "" "" "" "" "" "" "" ,$checkinfo);

  7.                                                                                                                                                                                                                                                                                                                                                                                                                /*********************Call functions************************** **** *********************************************

  8.                                                                        >

  9. Copy code


  10. function, action, false, count, detection



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