PHP strip_tags() Function


The strip_tags() function is used to strips a string from HTML, XML, and PHP tags.

Syntax
strip_tags(string,allow)
Parameters
  • string - (required)Specify the string to check.
  • allow - (optional)Specify the allowed tags.
Example
<?php
    echo strip_tags("<p>Good <b>morning</b></p>");
?>

Output

Good morning
Example - Strip the string from HTML tags, but allow h1 tags to be used:
<?php
    echo strip_tags("Good <h1>Morning!</h1>","<h1>");
?>

Output

Good

Morning!

Prev Next