In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use php plug-in HTMLPurifier, has a certain reference value, interested friends can refer to it, I hope you have a lot to gain after reading this article, let Xiaobian take you to understand it together.
Use of HTMLPurifier Plugin
Download HTMLPurifier Plugin
The useful part of the HTMLPurifier plugin is the library
Using HTMLPurifier library
the first way
The copy code is as follows:
or
The copy code is as follows:
An example given on the website is
The copy code is as follows:
require_once 'HTMLPurifier.auto.php';
My colleagues often use
The copy code is as follows:
require_once 'HTMLPurifier.includes.php';
require_once 'HTMLPurifier.autoload.php';
Set $config
configdoc
http://htmlpurifier.org/live/configdoc/plain.html
example
The copy code is as follows:
$config->set('HTML.AllowedElements', array('div'=>true, 'table'=>true, 'tr'=>true, 'td'=>true, 'br'=>true));
$config->set ('HTML. Doctype','XHTML 1.0 Transitional')//html Document type (standing)
$config->set ('Core.Encoding', ' UTF-8')//character encoding (permanent)
HTML allowed elements
div element, table element, tr element, td element, br element
new HTMLPurifier object
The copy code is as follows:
$purifier = new HTMLPurifier($config);
Call the purify method of the HTML Purifier object
The copy code is as follows:
$puri_html = $purifier->purify($html);
the second way
Custom a class HtmlPurifier.php
The copy code is as follows:
Set config information
For example:
The code is as follows:
$conf = array(
array('HTML.AllowedElements',
array(
'div' => true,
'table' => true,
'tr' => true,
'td' => true,
'br' => true,
),
false), //Allow attributes div table tr td br Element
array ('HTML.AllowedAttributes', array ('class' => TRUE), false), //AllowedAttributes class
array ('Attr. ForbiddenClasses', array ('resume_p' => TRUE), false), //forbid classes such as
array ('AutoFormat. RemoveEmpty', true, false), //remove spaces
array('AutoFormat.RemoveEmpty.RemoveNbsp', true, false), //Go nbsp
array('URI.Disable', true, false),
);
call
The code is as follows:
$p = new Resume_HtmlPurifier($conf);
$puri_html = $p->filter($html);
Thank you for reading this article carefully. I hope that Xiaobian will share the article "How to use php plugin HTMLPurifier". This article is helpful to everyone. At the same time, I hope that everyone will support you a lot. Pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.