Php filter all html tags _ PHP Tutorial

Source: Internet
Author: User
Php filters all html tags. 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. First, we recommend filter_sanitize_string and filter_sanitize_string filters to 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 &

*/

$ Var ="Bill gates";

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 ("helloWorld!");

// Hello world!

Function uh ($ str)
{
$ Farr = array (
"/S + /",
// Filter unnecessary spaces
"/<(/?) (Script | I? Frame | style | html | body | title | link | meta |? | %) ([^>] *?)> /Isu ",
// FilterTo join "/(<[^>] *) 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
?>

Characters removed from the filters or not required for encoding. This filter deletes data that is potentially harmful to the application. It...

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.