PHP JSON_ENCODE 不转义中文汉字的方法

WBOY
Release: 2016-06-23 13:53:15
Original
825 people have browsed it

ios程序中不识别读取到的JSON数据中 \u开头的数据。

PHP 生成JSON的时候,必须将汉字不转义为 \u开头的UNICODE数据。

网上很多,但是其实都是错误的,正确的方法是在json_encode 中加入一个参数 JSON_UNESCAPED_UNICODE (by default7#zbphp.com)

 json_encode($data, JSON_UNESCAPED_UNICODE); //必须PHP5.4+
Copy after login


官网的说明:http://php.net/manual/en/function.json-encode.php

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template