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

本文操作环境:Windows7系统、PHP7.1版,DELL G3电脑
php 怎么清除 script?
php去除html中的script
代码如下:
立即学习“PHP免费学习笔记(深入)”;
//去除 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的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号