Home  >  Article  >  Backend Development  >  PHP Prevents JS Injection Regular_PHP Tutorial

PHP Prevents JS Injection Regular_PHP Tutorial

WBOY
WBOYOriginal
2016-07-20 11:16:40925browse

   例子

代码如下  

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

代码如下  

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

  其它方法

代码如下  

$title="";
$title = strip_tags($title);
if(preg_match('/|<script>(.*)</script>|/',$title,$info)){
$title=$info['1'];
}else{
$title = $title;
}
echo $title;

代码如下  

$title="";
$title = strip_tags($title);
if(preg_match('/|<script>(.*)</script>|/',$title,$info)){
$title=$info['1'];
}else{
$title = $title;
}
echo $title;

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/372609.htmlTechArticleThe example code is as follows $a =/script[^]*?.*?/script/si; $keyword = preg_replace($a,' ',$_POST['searchword']); Other method codes are as follows?php $title=stylessss{'float:right'}/style; $titl...
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