php 怎么清除 script
- 建站笔记
- 2022-05-08
- 842
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 为空了。
本文由白琉璃于2022-05-08发表在白琉璃源码网,如有侵权或疑问,请联系我们,谢谢。
本文链接:https://www.bailiuli.com/t/3216.html
上一篇
php n的意思是什么
发表评论