PHP strip_tags() Function

Example

Remove HTML tags from the string:

<?php
echo strip_tags("Hello <b>world!</b>");
?>

Run Instance

Definition and Usage

strip_tags() function removes HTML, XML, and PHP tags from the string.

Note:This function always removes HTML comments. This cannot be allow Parameter changes.

Note:This function is binary safe.

Syntax

strip_tags(<
i>string,allow)
Parameter Description
string Required. Specify the string to be checked.
allow Optional. Specify the tags allowed. These tags will not be deleted.

Technical Details

Return Value: Returns the stripped string.
PHP Version: 4+
Update Log:

Since PHP 5.0, this function is binary safe.

Since PHP 4.3, this function always removes HTML comments.

More Examples

Example 1

Remove HTML tags from the string, but allow the use of <b> tags:

<?php
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
?>

Run Instance