PHP strip_tags() Function
Example
Remove HTML tags from the string:
<?php echo strip_tags("Hello <b>world!</b>"); ?>
Definition and Usage
strip_tags() function removes HTML, XML, and PHP tags from the string.
Note:This function will always strip 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 allowed tags. 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 will always strip 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>"); ?>