How to delete specified tags in php

青灯夜游
Release: 2023-03-10 07:44:01
Original
1844 people have browsed it

In PHP, you can use the strip_tags() function to delete specified tags. This function can strip HTML, XML and PHP tags in a string. The syntax format is "strip_tags(string,allow)"; parameter allow Specifies tags that can exist and will not be deleted.

How to delete specified tags in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

php delete specified tag

Example: Strip HTML tags from string:

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

Output:

How to delete specified tags in php

##Instructions:

# The ##strip_tags() function strips HTML, XML and PHP tags from strings. The syntax is as follows:

strip_tags(string,allow)
Copy after login

##ParameterDescriptionstringallowReturn value: Returns the stripped string.
Required. Specifies the string to check.
Optional. Specifies allowed tags. These tags will not be deleted.
Example: Strip HTML tags from a string, but allow tags:

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

Comment: This function always strips HTML comments. This cannot be changed via the allow parameter. How to delete specified tags in php

Recommended learning: "

PHP Video Tutorial

"

The above is the detailed content of How to delete specified tags in php. For more information, please follow other related articles on the PHP Chinese website!

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