htmlentities()函数 中文转成乱码问题
2017-05-27 22:15
190 查看
htmlentities — Convert all applicable characters to HTML entities
string htmlentities ( string
对于中文如果不指定第三个参数的话,中文就被转成乱码,解决方法就是把第二、第三个参数(UTF-8或GBK)都指定了。
echo htmlentities("高振安",ENT_NOQUOTES,GB2312)
echo htmlentities("高振安",ENT_NOQUOTES,"utf-8")
附 第二个参数可选值:
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")
附 第二个参数可选值:
ENT_COMPAT | Will convert double-quotes and leave single-quotes alone. |
ENT_QUOTES | Will convert both double and single quotes. |
ENT_NOQUOTES | Will leave both double and single quotes unconverted. |
ENT_IGNORE | Silently discard invalid code unit sequences instead of returning an empty string. Using this flag is discouraged as it ? may have security implications. |
ENT_SUBSTITUTE | Replace invalid code unit sequences with a Unicode Replacement Character U+FFFD (UTF-8) or FFFD; (otherwise) instead of returning an empty string. |
ENT_DISALLOWED | Replace invalid code points for the given document type with a Unicode Replacement Character U+FFFD (UTF-8) or FFFD; (otherwise) instead of leaving them as is. This may be useful, for instance, to ensure the well-formedness of XML documents with embedded external content. |
ENT_HTML401 | Handle code as HTML 4.01. |
ENT_XML1 | Handle code as XML 1. |
ENT_XHTML | Handle code as XHTML. |
ENT_HTML5 | Handle code as HTML 5. |
相关文章推荐
- PHP自带函数fgetcsv读取csv文件中文乱码问题解决办法
- escape函数解决js中ajax传递中文出现乱码问题
- 【php】php中urlencode函数及中文乱码问题
- php使用fputcsv()函数csv文件读写数据的方法(解决中文乱码问题)
- VS2010中wmain入口函数中使用wprintf输出中文乱码问题
- PHP json_encode() 函数详解及中文乱码问题
- Response.AddHeader函数中文件名的中文乱码问题的解决
- php 字符串操作函数substr()截取中文子串乱码问题
- htmlentities函数导致中文编码问题
- PHP json_encode() 函数详解及中文乱码问题
- Python模块函数:os.listdir 打印Win7目录中的文件-中文乱码问题
- PHP字符串截取函数(解决中文乱码问题!支持UTF-8和GB2312)
- Oracle字符拼接函数中文乱码问题
- PHP json_encode() 函数详解及中文乱码问题
- 关于PHP fopen函数在windows系统上创建中文命名的文档时乱码的问题
- substr中文乱码问题的解决,使substring函数代替
- 解决PHP substr() 函数的中文乱码问题
- escape函数解决js中ajax传递中文出现乱码问题
- php htmlentities汉字中文乱码问题解决办法
- Struts中文乱码问题解决