Home  >  Article  >  Backend Development  >  In a multi-coding environment, what format should be used for php and js data transmission?

In a multi-coding environment, what format should be used for php and js data transmission?

WBOY
WBOYOriginal
2016-08-08 09:06:41814browse

Currently, there are various encodings on the PHP side, including gbk, utf-8, big5, etc.

Now js needs to get the data from the server. If you use json format,

json_encode will return false if there is Chinese in the big5 encoding environment. Of course, I can use recursion to transcode the Chinese one by one and then re-json, but this does not feel like the best solution. Every time I go through such a set of transcoding, the performance will be reduced. affected.

I would like to ask if there are any other options? If not, you can only use this

Reply content:

Currently, there are various encodings on the PHP side, including gbk, utf-8, big5, etc.

Now js needs to get the data from the server. If you use json format,

json_encode will return false if there is Chinese in the big5 encoding environment. Of course, I can use recursion to transcode the Chinese one by one and then re-json, but this does not feel like the best solution. Every time I go through such a set of transcoding, the performance will be reduced. affected.

I would like to ask if there are any other options? If not, you can only use this

utf8 is the most reliable

Uniformly encode utf-8 unified format json on all ends

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