Home >Backend Development >PHP Problem >How to remove html tags in php

How to remove html tags in php

WJ
WJOriginal
2020-06-01 16:46:405412browse

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 的标签。

For example:

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

Non-standard HTML codes can also be removed correctly:

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

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!

Statement:
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