Home  >  Article  >  Backend Development  >  How to delete specified tags in php

How to delete specified tags in php

青灯夜游
青灯夜游Original
2021-05-31 17:58:251862browse

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

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)

##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>");
?>

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!

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