PHP implements the method of filtering the HTML tags in a form submission _php tutorial

Source: Internet
Author: User
Tags form post

PHP Implementation method to filter the HTML tags in the form submission


Sometimes we do a simple comment function will find that there are a lot of HTML tags submitted, these labels will cause the page to have some external connection, let's look at the HTML tag method of filtering form submission in PHP.

Some of the post links submitted by robots in recent reviews are spam reviews. In order to reduce this unnecessary link content appears, actually can use PHP to delete the form post submission HTML tag, so the machine submits the information also does not have the result which they want. And can reduce the penalty from seo/seo.html "target=" _blank "> Search engine.

Here to remove
Label For example:

In some cases we need to remove
tag, you can use the Str_replace function.

The code is as follows:

Remove BR Mark
$str =str_replace ("
"," ", $str);


To remove an HTML tag:
It can be done using the Strip_tags function.

Copy the code code as follows:

$str = Strip_tags ($STR);


Encapsulated as a function:

The code is as follows:

function removehtml ($STR) {
$str =str_replace ("
"," ", $str);
Return Strip_tags ($STR);
}
?>

http://www.bkjia.com/PHPjc/896779.html www.bkjia.com true http://www.bkjia.com/PHPjc/896779.html techarticle PHP Implementation method of filtering the HTML tags in the form submission sometimes we do a simple comment function will find that there are many submitted HTML tags, these tags will cause the page has some external connection, ...

  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.