PHP Html_entity_decode HTML entity escape

Source: Internet
Author: User
Recently encountered a problem, the data contains Chinese quotation marks, the results are escaped stored in the database, the data when the use of Htmlspecialchars_decode the entity escaped back, the results found not effective, looked at the Htmlspecialchars_ Decode only supports 5 specified entity conversions, others [I encountered a Chinese quotation mark &ldrquo;]
So I found out that html_entity_decode can escape all the entities back.

In addition, if you test in the browser, you will find that it is escaped back, because the browser is automatically processed. Actually did not turn back, can go to the command line to try Oh ~ ~

Html_entity_decode: Converts all HTML entities to their original characters
Contrary to Htmlentities ()
More precisely, this function decodes all entities (including all numeric entities): A) must be valid for the document type selected-that is, for XML, this function does not decode named entities that might be defined in some DTDs-and b) The character or character is in the encoded character set associated with the selected encoding and is allowed in the selected document type. All other entities remain intact.

Htmlspecialchars_decode: Converting special HTML entities back to normal characters
This function is exactly the opposite of Htmlspecialchars (). It converts special HTML entities back to normal characters.

The entities being converted are: &, "(When Ent_noquotes is not set), ' (when Ent_quotes is set), < and >.

So it is not possible to put the other conversions back that are not included in the above 5.

PHP Html_entity_decode HTML entity escape

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.