Home > Article > Backend Development > php remove html tag style
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.
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 = '<a href="">百度经验</a>,<b>欢迎您</b>'; echo $html;
Save the above content, view it in the browser, and clear the effect before HTML tags,
Use PHP's built-in function strip_tags() to clear HMTL tags. Example:
$eraser = strip_tags($html); echo $eraser;
Save the above content and compare the effects before and after the HTML tags are cleared
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,'<b>'); echo '保留<b>'.$bTag;
[Recommended learning: "PHP Video Tutorial"]
Save all the above content and view the comparison effect in the browser
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!