(PHP 4, PHP 5, PHP 7)
Remove the HTML and PHP tags from a string.
string strip_tags ( string $str [, string $allowable_tags ] )
This function tries to return a string by removing all HTML and PHP tags from str. Use the same system to remove the tags than fgetss () .
Parameters
-
str : The input string.
-
allowable_tags : You can use the second parameter, which is optional, to indicate tags that should not be removed.
Note : HTML comments and PHP tags are also removed. And this can not be modified with allowable_tags
.
Return
Returns the modified string.
$text = '<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>';
echo strip_tags($text); // Test paragraph. Other text
See the example by running on Ideone .