world!")]."/> world!")].">

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

How to remove html tags from string in php

王林
王林Original
2020-08-03 15:35:002852browse

How to delete html tags in a string in php: You can use php's built-in function strip_tags() to delete them. This function can strip HTML and XML tags in a string and return the stripped string, such as [strip_tags("Hello world!")].

How to remove html tags from string in php

The strip_tags() function strips HTML, XML and PHP tags from a string and returns the stripped string.

(Recommended tutorial: php graphic tutorial)

Syntax:

strip_tags(string,allow)

Parameters:

  • string Required. Specifies the string to check.

  • #allow Optional. Specifies allowed tags. These tags will not be deleted.

(Video tutorial recommendation: php video tutorial)

Example:

<?php
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
?>
<?php
echo strip_tags("Hello <b>world!</b>");
?>

The above is the detailed content of How to remove html tags from string 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

Related articles

See more