In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article focuses on "how php converts html entities into characters". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how php converts html entities into characters.
Conversion methods: 1, with html_entity_decode () function, you can convert HTML entities into characters; 2, with htmlspecialchars_decode () function, you can convert some predefined HTML entities ("", "&", etc.) into characters.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Php converts html entities to characters
1. Use the html_entity_decode () function
The html_entity_decode () function converts HTML entities to characters.
The html_entity_decode () function is the inverse of the htmlentities () function.
Syntax:
The html_entity_decode (string,flags,character-set) parameter is required to describe string. Specifies the string to be decoded. Flags is optional. Specifies how to handle quotation marks and which document type to use.
Available quotation mark types:
ENT_COMPAT-default. Decode only double quotation marks.
ENT_QUOTES-Decodes double and single quotation marks.
ENT_NOQUOTES-does not decode any quotation marks.
An additional flags that specifies the type of document to use:
ENT_HTML401-default. Handle the code as HTML 4.01.
ENT_HTML5-handles the code as HTML5.
ENT_XML1-handles the code as XML1.
ENT_XHTML-handles the code as XHTML.
Character-set is optional. A string that specifies the character set to be used.
Allowed values:
UTF-8-default. ASCII is compatible with multi-byte 8-bit Unicode
ISO-8859-1-Western Europe
ISO-8859-15-Western Europe (add euro symbol + missing French and Finnish letters in ISO-8859-1)
Cp866-DOS dedicated Cyrillic character set
Cp1251-Windows dedicated Cyrillic character set
Cp1252-Windows dedicated Western European character set
KOI8-R-Russian
BIG5-traditional Chinese, mainly used in Taiwan
GB2312-simplified Chinese, national standard character set
BIG5-HKSCS-Big5 with Hong Kong expansion
Shift_JIS-Japanese
EUC-JP-Japanese
MacRoman-character set used by the Mac operating system
Note: in versions prior to PHP 5.4, unrecognized character sets were ignored and replaced by ISO-8859-1. As of PHP 5.4, unrecognized character sets will be ignored and replaced by UTF-8.
Example 1: convert some HTML entities to characters:
Example 2: convert some HTML entities to characters by using the Western European character set:
2. Use the htmlspecialchars_decode () function
The htmlspecialchars_decode () function converts some predefined HTML entities into characters.
The HTML entities that will be decoded are:
& decode into & (and sign)
"decode into" (double quotation marks)
'Decode into'(single quotation marks)
< 解码成 < (小于) >Decode into > (greater than)
The htmlspecialchars_decode () function is the inverse of the htmlspecialchars () function. [related articles]
Syntax:
The htmlspecialchars_decode (string,flags) parameter is required to describe string. Specifies the string to be decoded. Flags is optional. Specifies how to handle quotation marks and which document type to use.
Available quotation mark types:
ENT_COMPAT-default. Decode only double quotation marks.
ENT_QUOTES-Decodes double and single quotation marks.
ENT_NOQUOTES-does not decode any quotation marks.
An additional flags that specifies the type of document to use:
ENT_HTML401-default. Handle the code as HTML 4.01.
ENT_HTML5-handles the code as HTML5.
ENT_XML1-handles the code as XML1.
ENT_XHTML-handles the code as XHTML.
Example: convert some predefined HTML entities to characters:
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.