预览模式: 普通 | 列表

htmlentities()函数 中文转成乱码问题

关键词:htmlentities 乱码

htmlentities — Convert all applicable characters to HTML entities

 
string htmlentities ( string $string [, int $flags = ENT_COMPAT | ENT_HTML401 [, string $encoding = 'UTF-8' [, bool $double_encode = true ]]] )
 
对于中文如果不指定第三个参数的话,中文就被转成乱码,解决方法就是把第二、第三个参数(UTF-8或GBK)都指定了。
 
echo htmlentities("太原网站建设",ENT_NOQUOTES,GB2312)
echo htmlentities("太原网络公司",ENT_NOQUOTES,"utf-8")
 

 

Tags: php

分类:技术文章 | 固定链接 | 评论: 0 | 引用: 0 | 查看次数: 383

 广告位

↑返回顶部↑