Home  >  Article  >  Backend Development  >  php remove html tag style

php remove html tag style

藏色散人
藏色散人Original
2021-03-15 09:19:322125browse

php method to remove html tag style: first create a PHP sample file; then define a piece of HTML text; finally use PHP's built-in function "strip_tags()" to clear the HMTL tag.

php remove html tag style

The operating environment of this article: Windows 7 system, PHP version 7.1, DELL G3 computer

Create a new PHP document and define a paragraph containing html tags String, example:

$html = &#39;<a href="">百度经验</a>,<b>欢迎您</b>&#39;;
echo $html;

php remove html tag style

Save the above content, view it in the browser, and clear the effect before HTML tags,

php remove html tag style

Use PHP's built-in function strip_tags() to clear HMTL tags. Example:

$eraser = strip_tags($html);
echo $eraser;

php remove html tag style

Save the above content and compare the effects before and after the HTML tags are cleared

php remove html tag style

If you need to retain certain HTML tags, strip_tags() has an optional second parameter, such as retaining the tag, example:

$bTag = strip_tags($html,&#39;<b>&#39;);
echo &#39;保留<b>&#39;.$bTag;

[Recommended learning: "PHP Video Tutorial"]

php remove html tag style

Save all the above content and view the comparison effect in the browser

php remove html tag style

The above is the detailed content of php remove html tag style. 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