Strip HTML tags from a string:
<?phpecho strip_tags("Hello <b>world!</b>");?>The strip_tags() function strips HTML, XML, and PHP tags from a string.
Comment: This function always strips HTML comments. This cannot be changed via the allow parameter.
Note: This function is binary safe.
strip_tags( string,allow )
parameter | describe |
---|---|
string | Required. Specifies the string to check. |
allow | Optional. Specifies allowed tags. These tags will not be deleted. |
Return value: | Returns the stripped string. |
---|---|
PHP version: | 4+ |
Update log: | As of PHP 5.0, this function is binary safe. As of PHP 4.3, this function always strips HTML comments. |
Strip HTML tags from a string but allow <b> tags:
<?phpecho strip_tags("Hello <b><i>world!</i></b>","<b>");?>