English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP String Manual of String Functions
The srip_tags() function is used to remove HTML and PHP tags from a string.
string strip_tags ( string $str [, string $allowable_tags ] )
This function attempts to return the result of the given string str after removing whitespace characters, HTML, and PHP tags.
Returns the processed string.
Serial Number | Parameters and Description |
---|---|
1 | string Input String |
2 | allow Use the optional second parameter to specify the list of characters not to be removed |
Try the following example, strip_tags deletes HTML tags and retains specified tags:
<?php $text = '<p>PHP Tutorial</p><!-- Comment --> <a href="#fragment">www.oldtoolbag.com</a>'; //Delete all HTML tags echo strip_tags($text); echo "\n"; // Do not delete the <p> and <a> tags echo strip_tags($text, '<p><a>'); ?>Test and See‹/›
Output Result
PHP Tutorial www.oldtoolbag.com PHP Tutorial www.oldtoolbag.com