Home > Backend Development > PHP Tutorial > 关于特殊字符的过滤.小弟我这有80分。

关于特殊字符的过滤.小弟我这有80分。

WBOY
Release: 2016-06-13 12:41:25
Original
914 people have browsed it

关于特殊字符的过滤...我这有80分。。
我现遇到一个问题,在提交表单时,对提交的内容要过滤掉特殊字符如:~!@#$%^&*()_+ ..这些
如我有一提交内容:生活*&)可以)(_更美的

如何过滤成:生活可以更美的。

我的做法是:
$str=str_replace("&","",$str);  
$str=str_replace(">","",$str);  
$str=str_replace(" $str=str_replace("=","",$str);
$str=str_replace("(","",$str);
$str=str_replace(")","",$str);
$str=str_replace("[","",$str);
$str=str_replace("]","",$str);
$str=str_replace(".","",$str);
$str=str_replace("*","",$str);
$str=str_replace("#","",$str);
$str=str_replace("$","",$str);
$str=str_replace("@","",$str);
$str=str_replace("-","",$str);
$str=str_replace("+","",$str);
$str=str_replace("&","",$str);  
$str=str_replace("!","",$str); 
$str=str_replace("~","",$str); 
$str=str_replace("^","",$str);
$str=str_replace("%","",$str);
$str=str_replace("'","",$str);
$str=str_replace("\"","",$str);

有没有更简便的方法。。求指教。。我这有80分。。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template