TA的每日心情 | 开心 2021-12-13 21:45 |
---|
签到天数: 15 天 [LV.4]偶尔看看III
|
在处理app接口的时候 ,中文在经过json_encode之后 变成\ \格式
想在返回接口的时候 中文不被转换 解决办法
第一种解决办法 - exit(json_encode($result,JSON_UNESCAPED_UNICODE));
- 第二种解决办法:
复制代码
- public function arrayRecursive(&$array, $function, $apply_to_keys_also = false)
- {
- static $recursive_counter = 0;
- if (++$recursive_counter > 1000)
- {
- die("possible deep recursion attack");
- }
- foreach ($array as $key => $value)
- {
- if (is_array($value))
- {
- $this->arrayRecursive($array[$key], $function, $apply_to_keys_also);
- }
- else
- {
- $array[$key] = $function($value);
- }
- if ($apply_to_keys_also && is_string($key))
- {
- $new_key = $function($key);
- if ($new_key != $key)
- {
- $array[$new_key] = $array[$key];
- unset($array[$key]);
- }
- }
- }
- $recursive_counter--;
- }
- public function json1($array)
- {
- $this->arrayRecursive($array, "urlencode", true);
- $json = json_encode($array);
- return urldecode($json);
- }
复制代码
调用exit($this->json($result));
|
|