Php filters all html tags

Source: Internet
Author: User

First, we recommend that the filter_sanitize_string and filter_sanitize_string filters remove or encode unnecessary characters.

This filter deletes data that is potentially harmful to the application. It is used to remove tags and delete or encode unnecessary characters.

Name: "string"
Id-number: 513
Possible options or flag:

Filter_flag_no_encode_quotes-this flag is not encoded with quotation marks
Filter_flag_strip_low-Remove characters with ascii values below 32
Filter_flag_strip_high-Remove characters with ascii values greater than 32
Filter_flag_encode_low-characters encoded with ascii values below 32
Filter_flag_encode_high-encode characters with ascii values greater than 32
Filter_flag_encode_amp-encode & character as & amp;

*/

$ Var = "<B> bill gates <B> ";

Var_dump (filter_var ($ var, filter_sanitize_string ));

/*
The second function is strip_tags.
The strip_tags () function removes tags from html, xml, and php tutorials.

Syntax
Strip_tags (string, allow)
*/

Echo strip_tags ("hello <B> world! </B> ");

// Hello world!

Function uh ($ str)
{
$ Farr = array (
"/S + /",
// Filter unnecessary Spaces
"/<(/?) (Script | I? Frame | style | html | body | title | link | meta |? | %) ([^>] *?)> /Isu ",
// Filter <script and other code that may introduce malicious content or maliciously change the display layout. If you do not need to insert flash, you can
To add <object Filtering
"/(<[^>] *) On [a-za-z] + s * = ([^>] *>)/isu ",
// Filter the on events of webpage Special Effects

);
$ Tarr = array (
"",
"<123>", // If You Want To directly clear insecure labels, leave it blank.
"12 ",
);

$ Str = preg_replace ($ farr, $ tarr, $ str );
Return $ str;
}

For more details, see http://www.bKjia. c0m/phper/19/70 dd2a905e74cefc9be9c0f17268dadc.htm
?>

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.