首頁 >後端開發 >php教程 >关于PHP5.4的htmlspecialchars_PHP教程

关于PHP5.4的htmlspecialchars_PHP教程

WBOY
WBOY原創
2016-07-13 17:52:19927瀏覽

今天项目升级到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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478129.htmlTechArticle今天项目升级到php5.4,gbk编码,htmlspecialchars转换后的字符串为空,郁闷啊 解决,加上编码吧,这么多地方用到htmlspecialchars,改起来真麻烦...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn