Htmlspecialchars of PHP5.4

Source: Internet
Author: User

Today, the project is upgraded to php5.4, gbk encoding, and the string converted by htmlspecialchars is empty. Why?

Solve the problem and add the encoding. htmlspecialchars is used in so many places. It is really troublesome to change it. It seems that you have to encapsulate it yourself in the future.


UPGRADING said:
[Html]
-The default character set for htmlspecialchars () and htmlentities () is
Now UTF-8. In previous versions it was ISO-8859-1. Note that changing
Your output charset via the php. ini default_charset directive does not
Affect htmlspecialchars/htmlentities unless you are passing "" (
Empty string) as the encoding parameter to your htmlspecialchars/htmlentities
CILS.

Also mentioned in the manual

[Html]
String htmlspecialchars (string $ string [, int $ flags = ENT_COMPAT | ENT_HTML401 [, string $ encoding = 'utf-8' [, bool $ double_encode = true])

[Html]
Defines encoding used in conversion. If omitted, the default value for this argument is ISO-8859-1 in versions of PHP prior to 5.4.0, and UTF-8 from PHP 5.4.0 onwards.


Author: xanxng

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.