PHP removes HTML tag functions--strip_tags and Htmlspecialchars

Source: Internet
Author: User

1, Strip_tags

Function: Remove HTML and PHP tags.

Syntax: string strip_tags (String str);

return value: String

Description: This function can remove any HTML and PHP tags contained in the string. If the HTML and PHP tags of the string are wrong, for example, less than the symbol is greater than the error will also be returned.

Note: When the refinement text is encountered, it will appear that the   space is not replaced by the number of lines above, this time requires a separate use of str_replace for a specific replacement  

2, Htmlspecialchars

Function: Converts special characters into HTML format.

Syntax: String htmlspecialchars (String string);

return value: String

This function converts special characters to HTML string format (&....;). The most commonly used occasion may be to deal with the message of the customer message version.

& (and) turn into &amp; "(double quotation marks) turn into &quot; < (less than) turn into &lt; > (greater than) turn into &gt;

This function converts only the above special characters, and does not convert all of the ASCII conversions specified by the HTML.

  • 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.