Home >Backend Development >PHP Problem >How to delete specified tags in php
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.
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:
# The ##strip_tags() function strips HTML, XML and PHP tags from strings. The syntax is as follows:
strip_tags(string,allow)
Required. Specifies the string to check. | |
Optional. Specifies allowed tags. These tags will not be deleted. |
<?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.
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!