PHP5.4 htmlspecialchars转义中文字符串变空
查看PHP官方文档htmlspecialchars函数(2014-9-12日):
string htmlspecialchars ( string $string
[, int $flags
= ENT_COMPAT | ENT_HTML401 [, string $encoding
= ini_get("default_charset") [, bool $double_encode
= true ]]] )
。。。
其中有这么一句:
If omitted, the default value of the encoding
varies depending on the PHP version in use. In PHP 5.6 and later, the default_charset configuration option is used as the default value. PHP 5.4 and 5.5 will use UTF-8 as the default. Earlier versions of PHP use ISO-8859-1.
大概意思:假如没有指定$encoding 这个参数,默认的值会要看PHP版本,PHP5.6以及PHP5.6以后的版本,默认值就是php.ini中的default_charset的选项值,PHP5.4和PHP5.5的默认值是UTF-8.PHP5.3以及更早版本默认使用的是ISO-8859-1。(19素材)
所以有些程序在使用这个函数在不同的PHP版本环境中可能会有问题,比如htmlspecialchars转义中文字符串变空等,因此使用的时候必须要注意。比如dedecms5.7GBK就有这个问题,后台详细介绍文本框就会出现htmlspecialchars转义中文字符串变空。(19素材)