Home > Backend Development > PHP Problem > What to do if php json Chinese characters are garbled

What to do if php json Chinese characters are garbled

藏色散人
Release: 2023-03-05 12:36:01
Original
2401 people have browsed it

php Solution to garbled json Chinese characters: First transcode the "Content" through the "urlencode" function; then use the "json_encode" function to json encode the variable.

What to do if php json Chinese characters are garbled

Recommended: "PHP Video Tutorial"

Pictured:

What to do if php json Chinese characters are garbled

Solution:

Use urlencode() to transcode the Content first, and then json_encode.

urlencode() encodes URL string function.

This function facilitates encoding a string and using it in the request part of the URL, and it also facilitates passing variables to the next page.

We often use this function to encode Chinese strings in URLs to avoid errors in URL calls.

json_encode — JSON encoding of variables

The above is the detailed content of What to do if php json Chinese characters are garbled. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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