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

What to do if php json Chinese characters are garbled

藏色散人
藏色散人Original
2020-08-29 09:54:232340browse

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!

Statement:
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