Home > Backend Development > PHP Problem > How to clear tags in php

How to clear tags in php

藏色散人
Release: 2023-03-03 10:56:01
Original
2529 people have browsed it

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

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

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!

Related labels:
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