Home > Backend Development > PHP Tutorial > PHP strip_tags() strips HTML tags from a string

PHP strip_tags() strips HTML tags from a string

不言
Release: 2023-03-29 08:30:01
Original
1809 people have browsed it

This article mainly introduces about PHP strip_tags() stripping HTML tags in strings. It has certain reference value. Now I share it with you. Friends in need can refer to

Definition and usage

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)
Parameter Description
string Required. Specifies the string to check.
allow Optional. Specifies allowed tags. These tags will not be deleted.

Example

<!DOCTYPE html><html><body><?phpecho strip_tags("Hello <b>world!</b>");echo strip_tags("Hello <b>world!</b>", "<b>");?></body></html>#展示
Hello world!
Hello 
world!
Copy after login

Related recommendations:

How to solve the problem that there is still a blank space after using strip_tags() to remove html tags in PHP

Instance analysis of strip_tags() in php only filters a certain tag in the string

The above is the detailed content of PHP strip_tags() strips HTML tags from a string. 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