How to convert php utf8 to gbk

藏色散人
Release: 2023-03-08 06:40:01
Original
2954 people have browsed it

php How to convert utf8 to gbk: First create a PHP sample file; then use the "iconv("UTF-8","gbk//TRANSLIT",$str); method to convert the string encoding from Just convert UTF-8 to GB2312.

How to convert php utf8 to gbk

The operating environment of this article: Windows 7 system, PHP version 5.6, DELL G3 computer.

php--utf8 and gbk conversion

utf8 to gbk

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

gbk to utf8

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

Recommended: "PHP Video Tutorial"

The above is the detailed content of How to convert php utf8 to gbk. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template