(PHP 4, PHP 5, PHP 7)
Removes 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. It uses the same system to remove tags from that fgetss().
Parameters
- str: The input string.
- allowable_tags: You can use the second parameter, which is optional, to indicate tags which must not be withdrawn.
Note: HTML comments and PHP tags are also removed. And this cannot 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 running on Ideone.
Taking advantage of the moment, read the guide on how to ask, especially the part about how to create a minimal, complete and verifiable example. Following the guides will surely increase the quality of the content in the community.
– Woss