今天项目升级到php5.4,gbk编码,htmlspecialchars转换后的字符串为空,郁闷啊
解决,加上编码吧,这么多地方用到htmlspecialchars,改起来真麻烦,看来以后得自己封装一下了。
upgrading说到
[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 (an
empty string) as the encoding parameter to your htmlspecialchars/htmlentities
calls.
手册中也说到
[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.
作者:xanxng
http://www.bkjia.com/phpjc/478129.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/478129.htmltecharticle今天项目升级到php5.4,gbk编码,htmlspecialchars转换后的字符串为空,郁闷啊 解决,加上编码吧,这么多地方用到htmlspecialchars,改起来真麻烦...
