php json_encode中文乱码解决办法
中文在php 开发中经常会有意无意的碰到问题,今天我们来看看json_encode中文乱码的解决办法吧,虽然方法不是很好,但可以解决问题只
代码如下 | 复制代码 |
$arr = array $jsonencode = json_encode($arr); |
结果如下
{"Name":null,"Age":20}
中文成了空,那是什么原因呢,下面接着看
我们来测试utf-8
代码如下 | 复制代码 |
$array = array echo json_encode($array); |
结果
{"title":"u8fd9u91ccu662fu4e2du6587u6807u9898","body":"abcd..."}
也不是我们想的东西,那我们利用php urlencode()函数处理以下,在json_encode之前,把所有数组内所有内容都用urlencode()处理一下
这样中文就没有问题了哦。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
