search

Home  >  Q&A  >  body text

What should I do if the string parsed by php json_encode is garbled?

For example,
$testStr = 'Hello, please help'; // It is in utf-8 format $testStr is a variable, so I don’t know if it is There is no garbled code, and the garbled code is somewhere, so the method of removing it by interception does not seem to work.

$testStr1 = json_encode($testStr);

var_dump($testStr1);

prints as false

It’s because there are garbled characters. How to parse the string with garbled characters? Please give me some advice. Thank you.

阿神阿神2763 days ago896

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-05-31 10:35:50

    http://php.net/manual/zh/func...

    reply
    0
  • ringa_lee

    ringa_lee2017-05-31 10:35:50

    php’s json_encode transcoding arrays containing Chinese characters requires adding parameters, json_encode($array, JSON_UNESCAPED_UNICODE).

    reply
    0
  • Cancelreply