php mysql html tags
I am having some trouble with strings which I get from my database. These strings include various html tags in them as well. For example:
"<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industrys standard</p>"
This is what I get from the database. How do I get rid of the <p>
tags in it? I have already tried strip_tags
and other functions to no avail.
These tags do not show up in the tinymce
开发者_开发知识库textareas
and the tags work there respective functionalities.
Use this function it will help you
function convertSpecialChars($string) {
$string = str_replace("&", "&", $string);
$string = str_replace("\n", "
", $string);
$string = str_replace("‘", "'", $string);
$string = str_replace(">", ">", $string);
$string = str_replace("<", "<", $string);
$string = str_replace("“", """, $string);
return $string;
}
enjoy...
strip_tags() if you want to remove HTML and PHP tags.
htmlspecialchars() if you want to keep HTML tags, but remove XSS possibility.
If I understod you correctly, you want to apply htmlentities
.
精彩评论