How to remove html tags in php

WJ
Release: 2023-03-01 11:06:02
Original
5371 people have browsed it

How to remove html tags in php

There is a strip_tags function in php that can easily remove HTML tags.

Usage is as follows:

echo strip_tags($html); // 去除 $html 中的 HTML、XML 以及 PHP 的标签。
Copy after login

For example:

$html = &#39;<div id="test"><span>www.anddd.com</span></div>&#39;;
echo strip_tags($html);//将会输出www.anddd.com
Copy after login

Non-standard HTML codes can also be removed correctly:

echo strip_tags(&#39;<a href="www.php.cn"></a>&#39;); //输出 www.php.cn
Copy after login

Related references: php中文网

The above is the detailed content of How to remove html tags in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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