定制 athoshun/html-filter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

athoshun/html-filter

最新稳定版本:v2.0.4

Composer 安装命令:

composer require athoshun/html-filter

包简介

Remove tags or attributes based on a whitelist from a snippet of well-formatted HTML text using PHP's DOM library

README 文档

README

Build Status Latest build report

Remove tags or attributes based on a whitelist from a snippet of somewhat well-formatted HTML text using PHP's DOM library.

Example:

<?php $config = new AthosHun\HTMLFilter\Configuration(); $config->allowTag("p") ->allowAttribute("a", "title") ->allowAttribute("a", "href", "|^https?://.*\$|"); $filter = new AthosHun\HTMLFilter\HTMLFilter(); $html = <<<HTML Lorem ipsum <em>dolor</em> sit amet <p>  Consectetur <a href="http://example.com" title="hey!">adipisicing</a>  <a href="javascript:alert(42)" onclick="alert(42)">elit</a>. </p> HTML; print $filter->filter($config, $html);

Output:

Lorem ipsum dolor sit amet <p> Consectetur <a href="http://example.com" title="hey!">adipisicing</a> <a>elit</a>. </p>

Installation

Installation is possible via Composer. Create a file named composer.json in your project directory with the following contents:

{ "require": { "athoshun/html-filter": "2.0.*" } } 

Then as a normal user, issue the following commands:

$ curl http://getcomposer.org/installer | php $ php composer.phar install 

统计信息

  • 总下载量: 39.76k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 19
  • 点击次数: 2
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 18
  • Watchers: 3
  • Forks: 4
  • 开发语言: PHP

其他信息

  • 授权协议: BSD
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固