Home > Backend Development > PHP Tutorial > PHP practical function for filtering special characters

PHP practical function for filtering special characters

WBOY
Release: 2016-07-25 08:54:02
Original
1333 people have browsed it
  1. // special character filter
  2. function htmldecode($str)
  3. {
  4. if(empty($str)) return;
  5. if($str=="") return $str;
  6. $str=str_replace("&",chr(34),$str);
  7. $str=str_replace(">",">",$str);
  8. $str=str_replace("<","<",$str);
  9. $str=str_replace("&","&",$str);
  10. $str=str_replace(" ",chr(32),$str);
  11. $str=str_replace(" ",chr(9),$str);
  12. $str=str_replace("'",chr(39),$str);
  13. $str=str_replace("
    ",chr(13),$str);
  14. $str=str_replace("''","'",$str);
  15. $str=str_replace("select","select",$str);
  16. $str=str_replace("join","join",$str);
  17. $str=str_replace("union","union",$str);
  18. $str=str_replace("where","where",$str);
  19. $str=str_replace("insert","insert",$str);
  20. $str=str_replace("delete","delete",$str);
  21. $str=str_replace("update","update",$str);
  22. $str=str_replace("like","like",$str);
  23. $str=str_replace("drop","drop",$str);
  24. $str=str_replace("create","create",$str);
  25. $str=str_replace("modify","modify",$str);
  26. $str=str_replace("rename","rename",$str);
  27. $str=str_replace("alter","alter",$str);
  28. $str=str_replace("cas","cast",$str);
  29. //电影学堂 http://bbs.it-home.org
  30. $farr = array(
  31. "//s+/" , // filter 多余的答面
  32. "/<(//?)(img|script |i?frame|style|html|body|title|link|meta|/?|/%)([^>]*?)>/isu" , // filter
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template