search

Home  >  Q&A  >  body text

Chinese display garbled characters problem

I just started learning PHP, configured apache2.4 php7, and wrote a few lines with Notepad

<?PHP

echo "Welcome to PHP!";

?>

When opened with IE and Google, Chinese characters are displayed as garbled characters. . . I haven't been able to find the answer for a whole day. . Seeking experts. .


杨一鸣杨一鸣2335 days ago1363

reply all(2)I'll reply

  • Hello World!

    Hello World!2018-08-06 14:40:30

    Need to add at the top of the PHP file: header('Content-type:text/html;charset=utf-8');

    reply
    0
  • 杨一鸣

    Well, I later added this header("content-type:text/html;charset=GB2312"); and it worked. I tried again and changed charset=GB2312 to charset=utf-8, but it was still garbled. I still have some problems with this encoding. Confused, check some more information.

    杨一鸣 · 2018-08-06 14:45:46
  • 无名指

    无名指2018-08-06 08:16:09

    Try adding a sentence before the output: header("Content-type:text/html;charset=utf-8");

    reply
    0
  • Cancelreply