PHP strip_tags() function to remove HTML, XML and PHP tags from strings

高洛峰
Release: 2023-03-04 14:44:01
Original
1511 people have browsed it

strip_tags 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)

PHP strip_tags() function to remove HTML, XML and PHP tags from strings

Technical details

PHP strip_tags() function to remove HTML, XML and PHP tags from strings

strip_tags Example 1,

Strip the HTML tags in the string:

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

Result

Hello world!,

Example 2

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

Result

Hello world!

For more PHP strip_tags() function to remove HTML, XML and PHP tags in strings, please pay attention to the PHP Chinese website for related articles!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!