Discover remove html tags from string in php, include the articles, news, trends, analysis and practical advice about remove html tags from string in php on alibabacloud.com
Remove unnecessary HTML tags from php
Echo strip_tags ($ str );
2. retain onlyFor a tag, you only needThe string is written to the second parameter of strip_tags.
Echo strip_tags ($ str ,"");
3.
PHP implementation of closed HTML tags, PHP complement HTML tags
The example in this article describes the HTML tags that PHP implements to close. Share to everyone for your reference, as follows:
Most of the time, when we make a fuss about
PHP strip_tags () goes to the function of HTML, XML, and PHP tags in the string, Strip_tagsxml
Strip_tags Definition and usage
The Strip_tags () function strips the HTML, XML, and PHP tags from the string.
Note: This function always strips HTML
How php deletes html tags
This article introduces three methods to delete html tags using php. For more information, see.Method 1: directly retrieve the desired tag. Use php functions: str_replace, htmlspecialchars, and strip_tags.
","
This article is a PHP deletion of HTML tags in the three solutions to the detailed analysis of the introduction, the need for friends to refer to the
Method 1:directly remove the tag you want to remove
Copy Code code as follows:
//Remove BR
This article describes the use of PHP to remove HTML tags three ways, with the need for friends, refer to the next bar.Method 1, remove the desired tag directly. PHP functions are used: Str_replace, Htmlspecialchars, Strip_tags.
"," ", $str);/
Method 1:Directly remove the mark you want to remove
Copy CodeThe code is as follows:
Remove BR Mark
function strip ($STR)
{
$str =str_replace ("
"," ", $str);
$str =htmlspecialchars ($STR);
Return Strip_tags ($STR);
}
?>
Method 2.PHP has a
Explanation of native functions for php to remove html tags, and explanation of php tag functions. Php native functions for removing html tags; php tag functions for strip_tags for removing HTML and PHP tags. Syntax: stringstrip_tags (stringstr);
Method 1:Directly remove the tag you want to remove
Copy Code code as follows:
Remove the BR mark
function strip ($STR)
{
$str =str_replace ("", "", $str);
$str =htmlspecialchars ($STR);
Return Strip_tags ($STR);
}
?>
In php, the most common HTML tag can be replaced by the strip_tags function, which can be used to filter all html tags, next I will introduce other methods besides this function.
Sometimes we need to store html tabs in the database, but in some
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.