Strip HTML and PHP tags from a string.

1.0.0 2017-11-24 13:47 UTC

This package is not auto-updated.

Last update: 2023-09-22 15:32:20 UTC


(PHP 5 >= 5.4)
strip_html — Strip HTML and PHP tags from a string.


string strip_html( string $str )

This function tries to return a string with all NULL bytes, HTML and PHP tags stripped from a given str. Unlike strip_tags(), this function is mindful of line-breaks and metadata elements (e.g., <style>).

This function is useful for converting a HTML-rich string into a plain-text string for emails.


  • str — The input string.

Return Values

Returns the stripped string.


With Composer

$ composer require mcaskill/php-strip-html

Without Composer

Why are you not using composer? Download Function.Strip-HTML.php from the gist and save the file into your project path somewhere.