Home  >  Article  >  php教程  >  PHP防止JS注入正则

PHP防止JS注入正则

WBOY
WBOYOriginal
2016-06-13 11:32:201409browse

   例子

代码如下  

$a ="/<script>]*?>.*?</script>/si";
$keyword = preg_replace($a,' ',$_POST['searchword']);

  其它方法

代码如下  

$title="";
$title = strip_tags($title);
if(preg_match('/|<script>(.*)</script>|PHP防止JS注入正则/',$title,$info)){
$title=$info['1'];
}else{
$title = $title;
}
echo $title;

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