In this article, we will see how to remove HTML tags from data in PHP. PHP provides an inbuilt function to remove the HTML tags from the data. The strip_tags() function is an inbuilt function in PHP that removes the strings form HTML, XML and PHP tags. It accepts two parameters. This function returns a string with all NULL bytes, HTML, and PHP tags stripped from a given $str. Show Syntax: strip_tags(string, allowed_tags) Parameters Values:
Return Value: It returns a string where HTML tags are removed except for the allowed tags. Example 1: In this example, we passed a string containing HTML tags to the strip_tags() function and checked the returned string whether all HTML tags are removed or not. All the HTML tags in the string are stripped from the string by the strip_tags() function. PHP
Output:
Example 2: In this code, we specified the allowed_tags parameter along with the string to strip_tags() method, so that we can allow a few tags in the string and strip the unallowed tags from the input string. In the allowed_tags section, we specified tag. So it did not strip the |