PHP——json_encode转码保留中文

前言

特殊的情况,特殊对待吧。转码为GBK再json_encode会报错,因为json_encode是只支持utf8的。

代码

文档 | https://www.php.net/manual/en/function.json-encode.php

参数 | https://www.php.net/manual/en/json.constants.php

$json_request = json_encode($RequestBoday, JSON_UNESCAPED_UNICODE);

JSON_UNRSCAPED_UNICODE

从字面上对多字节Unicode字符进行编码(默认为以 uXXXX转义)。从PHP 5.4.0开始提供。

函数

json_encode常量

json_decode常量

原文地址:https://www.cnblogs.com/wangyang0210/p/10905591.html