Home  >  Article  >  Backend Development  >  How to clear tags in php

How to clear tags in php

藏色散人
藏色散人Original
2020-07-27 09:45:102450browse

You can use the built-in "strip_tags" function in php to clear tags. This function always strips HTML comments. Its syntax is "strip_tags(string,allow)". The parameter "string" represents the character to be checked. string.

How to clear tags in php

Recommended: "PHP Tutorial"

strip_tags definition and usage

# The ##strip_tags() function strips HTML, XML and PHP tags from strings.

Comments: This function always strips HTML comments. This cannot be changed via the allow parameter.

Note: This function is binary safe.

Syntax

strip_tags(string,allow)

Parameters

string Required. Specifies the string to check.

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

Return value: Returns the stripped string.

PHP Version: 4

Change Log:

Since PHP 5.0, this function is binary safe.

Since PHP 4.3, this function always strips HTML comments.

Example

Strip the HTML tags in the string, but allow the tag:

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

Run result:

How to clear tags in php

The above is the detailed content of How to clear 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