Home  >  Article  >  Backend Development  >  php function to remove html tags

php function to remove html tags

藏色散人
藏色散人Original
2021-02-24 09:42:062487browse

php's function to remove html tags is "strip_tags". The function of this function is to strip HTML, XML and PHP tags from strings. Its usage syntax is "strip_tags(string,allow)".

php function to remove html tags

#The operating environment of this article: Windows7 system, PHP7.1, Dell G3 computer.

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.

Example

Strip HTML tags in string:

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

Output:

Hello world!

[Recommended: PHP video tutorial

The above is the detailed content of php function to remove html tags. 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