php5.4以上版本GBK编码下htmlspecialchars输出为空问题解决方法汇总
从旧版升级到php5.4,恐怕最麻烦的就是htmlspecialchars这个问题了!当然,htmlentities也会受影响,不过,对于中文站来说一般用htmlspecialchars比较常见,htmlentities非常少用到。
可能老外认为网页普遍应该是utf-8编码的,于是苦了那些用GB2312,GBK编码的中文站......!
具体表现:
$str="9enjoy.com的php版本是5.2.10"; echohtmlspecialchars($str);
gbk字符集下输出为空...utf-8下,输出正常。
为什么呢,原因在于5.4.0对这个函数的变化:
5.4.0 ThedefaultvaluefortheencodingparameterwaschangedtoUTF-8.
原来是什么呢?
stringhtmlspecialchars(string$string[,int$flags=ENT_COMPAT|ENT_HTML401[,string$encoding='UTF-8'[,bool$double_encode=true]]])
Definesencodingusedinconversion.Ifomitted,thedefaultvalueforthisargumentisISO-8859-1inversionsofPHPpriorto5.4.0,andUTF-8fromPHP5.4.0onwards.
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下