Home >Backend Development >PHP Problem >How to convert php gbk to utf
php gbk to utf method: First create a PHP sample file; then use the "iconv('GB2312', 'UTF-8', $str);" method to convert the string encoding from GB2312 UTF8 is enough.
Recommended: "PHP Video Tutorial"
php Convert utf8 and gbk to each other
utf8 to 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 to utf8
<?php header("Content-type:text/html;charset=GB2312"); echo $str= '你好,这里是gbk转utf8!'; echo '<br />'; echo iconv('GB2312', 'UTF-8', $str); //将字符串的编码从GB2312转到UTF-8
The above is the detailed content of How to convert php gbk to utf. For more information, please follow other related articles on the PHP Chinese website!