PHP中如何实现UTF-8编码转换功能?
- 内容介绍
- 文章标签
- 相关推荐
本文共计304个文字,预计阅读时间需要2分钟。
在PHP中,使用iconv函数进行UTF-8转换的语法是 `iconv(string $in_charset, string $out_charset, string $str)`。在Windows 7系统、PHP 7.1版本、DELL G3电脑上,若要使用iconv函数将字符串从UTF-8转换到其他编码,可以使用以下代码:
phpstring iconv_utf8(string $str, string $out_charset) { return iconv(UTF-8, $out_charset, $str);}
php utf8转换函数是iconv,该函数的使用语法是“string iconv ( string in_charset, string out_charset, string str )”。
本文操作环境:windows7系统、PHP7.1版,DELL G3电脑
php utf8 转换函数是什么?
string iconv ( string in_charset, string out_charset, string str )
注意:第二个参数,除了可以指定要转化到的编码以外,还可以增加两个后缀:
//TRANSLIT 和 //IGNORE,其中 //TRANSLIT 会自动将不能直接转化的字符变成一个或多个近似的字符,//IGNORE 会忽略掉不能转化的字符,而默认效果是从第一个非法字符截断。
Returns the converted string or FALSE on failure.
示例
GBK To UTF-8
$content = iconv("UTF-8", "GBK//IGNORE",$content);
推荐学习:《PHP视频教程》
以上就是php utf8 转换函数是什么的详细内容,更多请关注自由互联其它相关文章!
本文共计304个文字,预计阅读时间需要2分钟。
在PHP中,使用iconv函数进行UTF-8转换的语法是 `iconv(string $in_charset, string $out_charset, string $str)`。在Windows 7系统、PHP 7.1版本、DELL G3电脑上,若要使用iconv函数将字符串从UTF-8转换到其他编码,可以使用以下代码:
phpstring iconv_utf8(string $str, string $out_charset) { return iconv(UTF-8, $out_charset, $str);}
php utf8转换函数是iconv,该函数的使用语法是“string iconv ( string in_charset, string out_charset, string str )”。
本文操作环境:windows7系统、PHP7.1版,DELL G3电脑
php utf8 转换函数是什么?
string iconv ( string in_charset, string out_charset, string str )
注意:第二个参数,除了可以指定要转化到的编码以外,还可以增加两个后缀:
//TRANSLIT 和 //IGNORE,其中 //TRANSLIT 会自动将不能直接转化的字符变成一个或多个近似的字符,//IGNORE 会忽略掉不能转化的字符,而默认效果是从第一个非法字符截断。
Returns the converted string or FALSE on failure.
示例
GBK To UTF-8
$content = iconv("UTF-8", "GBK//IGNORE",$content);
推荐学习:《PHP视频教程》
以上就是php utf8 转换函数是什么的详细内容,更多请关注自由互联其它相关文章!

