Htmlspecialchars () and Htmlspecialchars_decode ()

Source: Internet
Author: User

The Htmlspecialchars_decode () function is an inverse function of the htmlspecialchars () function.

htmlspecialchars () can be used to prevent XSS; Refer to: https://www.zhihu.com/question/27646993

Htmlspecialchars_decode () function

More examples of examples 1

To convert a predefined HTML entity to a character:

Do not convert any quotation marks?>

The HTML output of the above code is as follows (see source code):

<! DOCTYPE Html>

The browser output of the above code:

Bill & ' Steve ' Bill & ' Steve ' Bill & ' Steve '
Example 2

To convert a predefined HTML entity to double quotes:

Convert double and single quotation marks?>

The HTML output of the above code is as follows (see source code):

<! DOCTYPE html>

The browser output of the above code:

I Love "PHP".


Htmlspecialchars () function:

More examples of examples 1

Convert some of the predefined characters to HTML entities:

Do not convert any quotation marks?>

The HTML output of the above code is as follows (see source code):

<! DOCTYPE Html>

The browser output of the above code:

Bill & ' Steve ' Bill & ' Steve ' Bill & ' Steve '

Htmlspecialchars () and Htmlspecialchars_decode ()

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.