What is the usage of the php strip_tags function?
The strip_tags() function is used to remove HTML and PHP tags from a string. Its syntax is as follows:
string strip_tags ( string $str [, string $allowable_tags ] )
The parameter ‘str’ is the string from which tags need to be removed, ‘allowable_tags’ is an optional parameter used to specify which tags can be retained.
If the allowable_tags parameter is not specified, the function will remove all tags from the string. If the allowable_tags parameter is specified, only the specified tags will be retained and all other tags will be removed.
For example:
$text = "<p>This is a <b>bold</b> and <i>italic</i> text.</p>";
echo strip_tags($text); // 输出:This is a bold and italic text.
echo strip_tags($text, "<b>"); // 输出:<p>This is a <b>bold</b> and italic text.</p>