Usage of strip_tags function in php: [strip_tags(string,allow)]. The strip_tags function is used to strip HTML, XML and PHP tags from strings.
php strip_tags function is used to strip HTML tags from strings. Its syntax is strip_tags(string,allow). The parameter string is required and is specified to be checked. The string, allow is optional and specifies the allowed tags.
(Related recommendations: php training)
How to use the php strip_tags function?
Function: Strip HTML tags in strings
Syntax:
strip_tags(string,allow)
Parameters:
string Required, specifies the characters to be checked string.
allow Optional, specifies allowed tags. These tags will not be deleted.
Description: The strip_tags() function strips HTML, XML and PHP tags from the string. This function always strips HTML comments. This cannot be changed via the allow parameter. This function is binary safe.
php strip_tags() function usage example 1:
<?php echo strip_tags("<p>Hello <b>world!</b></p>","<b>"); ?>
Output:
Hello world
php strip_tags() function usage example 2:
<?php $i = "<b>hello<i> php.cn</i></b>"; $j = strip_tags($i,'<i>'); echo $j; ?>
Output:
hello <i>php.cn</i>
The above is the detailed content of How to use the strip_tags function in php. For more information, please follow other related articles on the PHP Chinese website!