Home > Backend Development > PHP Problem > php remove html tag style

php remove html tag style

藏色散人
Release: 2023-03-08 17:44:01
Original
2172 people have browsed it

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;
Copy after login

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;
Copy after login

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;
Copy after login

[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!

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