php完全过滤HTML,JS,CSS等标签
时间:2023-10-09 08:07:34
记得以前写过一篇文章
php有效的过滤html标签,js代码,css样式标签:
<?php
$str = preg_replace( "@<script(.*?)</script>@is", "", $str );
$str = preg_replace( "@<iframe(.*?)</iframe>@is", "", $str );
$str = preg_replace( "@<style(.*?)</style>@is", "", $str );
$str = preg_replace( "@<(.*?)>@is", "", $str );
?>
,全是正则过滤HTML标签,但是今天自己拿来用都不好用了.原因??就是标签转义了.比如<br >.页面上显示的是这个.但是源文件却显示的像这样:”——但是我们还是可以处理,先把内容全部反编译过来.再过滤就行了.
$str= htmlspecialchars_decode($str);
用htmlspecialchars_decode这个函数的就是把源文件转成<>这样的标签.然后”:
$str= preg_replace("/<(.*?)>/","",$str);
标签:php,完全过滤,HTML,JS,CSS
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
批量替换 MySQL 指定字段中的字符串
2024-01-18 22:17:23
SQL Server 2005 还原数据库错误解决方法
2024-01-14 05:45:43
![](https://img.aspxhome.com/file/2023/2/125682_0s.jpg)
浅谈Pytorch中的torch.gather函数的含义
2022-12-26 02:25:54
![](https://img.aspxhome.com/file/2023/2/114612_0s.jpg)
PHP遍历目录函数opendir()、readdir()、closedir()、rewinddir()总结
2024-05-03 15:53:21
python学习之panda数据分析核心支持库
2023-11-04 17:39:29
![](https://img.aspxhome.com/file/2023/0/115640_0s.png)
Python补齐字符串长度的实例
2023-09-24 21:51:43
php实现统计二进制中1的个数算法示例
2024-06-05 09:39:05
![](https://img.aspxhome.com/file/2023/5/122535_0s.png)
mysql复制中临时表的运用技巧
2024-01-20 10:51:49
Python获取二维矩阵每列最大值的方法
2022-08-28 00:26:16
python连接mongodb数据库操作数据示例
2024-01-14 19:16:54
Python随机数模块详情
2021-10-26 06:47:34
Go语言Goroutinue和管道效率详解
2024-02-02 18:19:09
![](https://img.aspxhome.com/file/2023/5/113075_0s.jpg)
Python操作JSON实现网络数据交换
2023-01-27 02:21:53
python GUI库图形界面开发之PyQt5访问系统剪切板QClipboard类详细使用方法与实例
2021-08-06 03:48:32
![](https://img.aspxhome.com/file/2023/5/90315_0s.png)
python的列表List求均值和中位数实例
2023-07-09 13:06:16
scrapy结合selenium解析动态页面的实现
2023-11-11 17:16:51
![](https://img.aspxhome.com/file/2023/1/131381_0s.jpg)
python3 queue多线程通信
2022-09-20 08:41:05
![](https://img.aspxhome.com/file/2023/7/135197_0s.png)
MySQL 8.0新功能监控统计限制连接不再担心被垃圾SQL搞爆内存
2024-01-16 12:51:25
linux服务器下PHPCMS v9 安全配置详解
2023-11-17 11:51:52
如何“看看”服务器上的那个文件还在不在?
2009-11-02 20:17:00