This article illustrates the way PHP implements HTML tags in filtering form submissions. Share to everyone for your reference. The implementation methods are as follows:
Sometimes the simple comment feature we do will find that there are a lot of HTML tags that will cause the page to have some external connection, so let's look at the HTML tagging method for filtering form submissions in PHP.
Some of the post links submitted by robots in recent comments are spam comments. In order to reduce this unnecessary link content appears, actually can use PHP to delete form Post submitted HTML tags, so the machine submitted information will not get the results they want. And can reduce the penalty from the seo/seo.html "target=" _blank > Search engine.
Here to remove the <br/> label as an example:
In some cases we need to remove the <br/> tag and use the Str_replace function.
Copy Code code as follows:
Remove the BR mark
$str =str_replace ("<br>", "", $str);
To remove an HTML tag:
Can be done using the Strip_tags function.
Copy Code code as follows:
$str = Strip_tags ($STR);
Encapsulated into a function:
Copy Code code as follows:
<?php
function removehtml ($STR) {
$str =str_replace ("<br>", "", $str);
Return Strip_tags ($STR);
}
?>
I hope this article will help you with your PHP program design.