编程爱好者之家

php utf8编码和gbk编码相互转换

2018-11-26 371

1.utf8转换为gbk

header("Content-type:text/html;charset=UTF-8");
echo $str= 'utf8转gbk!';
echo '<br />';
echo iconv("UTF-8","gbk//TRANSLIT",$str); //将字符串的编码从UTF-8转到GB2312

2.gbk转utf8

header("Content-type:text/html;charset=GB2312");
echo $str= 'gbk转utf8!';
echo '<br />';
echo iconv('GB2312', 'UTF-8', $str); //将字符串的编码从GB2312转到UTF-8


同类文章

您的赞赏是对小编最大的支持!