search

Home  >  Q&A  >  body text

PHP reads the file content through fread(). How to solve the problem of garbled Chinese characters?

In PHP, files are read directly through the fread function. If the file content encounters Chinese characters, the problem will be garbled. How to solve this problem?

我想大声告诉你我想大声告诉你2751 days ago1478

reply all(2)I'll reply

  • phpcn_u1582

    phpcn_u15822017-05-16 13:12:49

    Try transcoding the content after reading it

    iconv('gbk', 'utf-8', $data)

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:12:49

    That’s because the encoding of your output page is inconsistent with the encoding of the file being read

    reply
    0
  • Cancelreply