Htmlspecialchars () and htmlentities () of php functions

Source: Internet
Author: User
When the web editor writes articles to the database or reads the database content, there are often non-resolution issues and a lot of code, which is actually a problem of html entity and corresponding string conversion. It mainly involves htmlspecialchars (), htmlentities (), htmlspecialchars _... "/> <scripttype =" text/javasc

 


When the web editor writes articles to the database or reads the database content, there are often non-resolution issues and a lot of code, which is actually a problem of html entity and corresponding string conversion.

It mainly involves functions such as htmlspecialchars (), htmlentities (), and htmlspecialchars_decode.


The htmlspecialchars () function converts some predefined characters into HTML objects.

The predefined characters are:

& (And number) become &

"(Double quotation marks)"

'(Single quotes)'

<(Less than) becomes <

> (Greater than) become>

 

 

PHP htmlentities () function

Definition and usage

The htmlentities () function converts characters to HTML objects.

Syntax

Htmlentities (string, quotestyle, character-set)

Note the differences between the two.

 

 

PHP htmlspecialchars_decode () function

Definition and usage

The htmlspecialchars_decode () function converts some predefined HTML entities into characters.

The HTML entity to be decoded is:

& Became & (and)

"Become" (double quotation marks)

'Become '(single quotes)

<Become <(less)

> Become> (greater)

 

 

 

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.