PHP strip_tags()Functions
Examples
Strip HTML tags from a string:
<?php
echo strip_tags("Hello <b>world!</b>");
?>
echo strip_tags("Hello <b>world!</b>");
?>
Run example »
Definition and Usage
The strip_tags() function strips HTML, XML, and PHP tags from a string.
Note:This function always strips HTML comments. This cannot be changed with the allow parameter.
Note:This function is binary-safe.
Syntax
strip_tags(string,allow)
| Parameter | Description |
|---|---|
| string | Required. Specifies the string to be checked. |
| allow | Optional. Specifies allowed tags. These tags will not be removed. |
Technical Details
| Return value: | Returns the stripped string. |
|---|---|
| PHP Version: | 4+ |
| Changelog: | As of PHP 5.0, this function is binary-safe. As of PHP 4.3, this function always strips HTML comments. |
More Examples
Example 1
Strip HTML tags from a string, but allow <b> tags:
<?php
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
?>
echo strip_tags("Hello <b><i>world!</i></b>","<b>");
?>
Run example »
PHP String Reference Manual Other Extensions