Home > Backend Development > PHP Tutorial > PHP completely filters HTML, JS, CSS and other tags_PHP tutorial

PHP completely filters HTML, JS, CSS and other tags_PHP tutorial

WBOY
Release: 2016-07-21 15:47:59
Original
1118 people have browsed it

I remember writing an article before
php effectively filters html tags, js code, css style tags:

Copy the code The code is as follows:

$str = preg_replace( "@@is", "", $str );
$str = preg_replace( "@@is", "", $str );
$str = preg_replace( "@$str = preg_replace( "@<(.*?)>@is", "", $str );
?>

are all regular filtering HTML tags, but today they are not easy to use. The reason is that the tags are escaped. For example,
. This is what is displayed on the page. But the source file is displayed like this: "——But we can still deal with it, first decompile all the contents. Then filter it.
Copy code The code is as follows:

$str= htmlspecialchars_decode($str);

Using the htmlspecialchars_decode function is to convert the source file into a tag like <>. Then":
Copy code The code is as follows:

$str= preg_replace("/<(.*?)> ;/","",$str);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/319819.htmlTechArticleI remember I wrote an article before that php can effectively filter html tags, js code, css style tags: Copy code code As follows: ?php $str = preg_replace( "@script(.*?)/script@is", "", $str ); $str...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template