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