How to solve the problem of Chinese garbled codes in gbk and gb2312 handled by json_encode in php
The content of this article mainly explains "how to solve the Chinese garbled code of json_encode in php dealing with gbk and gb2312". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "how to solve the Chinese garbled code of gbk and gb2312 in json_encode in php"!
This paper describes the solution of json_encode in php to deal with the problem of garbled codes in gbk and gb2312. The specific methods are as follows:
1.json_encode () Chinese is returned as null for Chinese in gbk/gb2312
$arr = array (array ('catid' = >' 44th, 'catname' = >' www.jb51.net', 'meta_title' = >''); echo json_encode ($arr)
Running result:
[{"catid": "4", "catname": "www.jb51.net", "meta_title": null}]
Have you seen "meta_title": null, he used to have a value of "". We checked that the principle is that json_encode only supports uft-8 encoding. Let's convert it.