php 怎么清除 script

php 怎么清除 script,第1张

php 怎么清除 script

php清除script的方法:1、创建一个PHP示例文件;2、通过“function delScript($string){...}”方法去除html中的script即可。

本文 *** 作环境:Windows7系统、PHP7.1版,DELL G3电脑

php 怎么清除 script?

php去除html中的script

代码如下:

//去除 script 脚 本
function delScript($string){
   $pregfind = array("/<script.*>.*<//script>/siU",'/on(mousewheel|mouseover|click|load|onload|submit|focus|blur)="[^"]*"/i');
   $pregreplace = array('','');
   $string = preg_replace($pregfind, $pregreplace, $string);
   return $string;
}

主要是 将<script></script> 及中间的部分给 replace 为空了。

推荐学习:《PHP视频教程》

以上就是php 怎么清除 script的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/679617.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-20
下一篇 2022-04-20

发表评论

登录后才能评论

评论列表(0条)

保存