php-----utf8和gbk相互转换

utf8转换为gbk

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

 

gbk转换为utf8

<?php
header("Content-type:text/html;charset=GB2312");
echo $str= '你好,这里是gbkutf8!';
echo '<br />';
echo iconv('GB2312', 'UTF-8', $str); //将字符串的编码从GB2312转到UTF-8

 

posted @ 2018-01-10 14:51  切切歆语  阅读(32848)  评论(0编辑  收藏  举报