Home >Backend Development >PHP Problem >What should I do if the message returned by php WeChat is garbled?
php The solution to the garbled message returned by WeChat: 1. Create a PHP sample file; 2. Encode it through the "urldecode(json_encode($message));" method.
The operating environment of this article: windows7 system, PHP version 7.4, DELL G3 computer
php Why is the message returned by WeChat garbled? What to do?
Solution to garbled push messages sent by PHP WeChat
Use urlencode first because Chinese will be encoded when the array is converted to json Unicode cannot be recognized by the WeChat interface, so you need to encode it before json_encode, and then use urldecode to convert it back after conversion, so that what is transmitted to the interface is normal Chinese.
Reference code:
##
$message = array( 'touser'=>$touser, 'msgtype'=>'text', 'text'=>array('content'=>urlencode($text)) ); $message = urldecode(json_encode($message));Recommended learning: "
PHP Video Tutorial"
The above is the detailed content of What should I do if the message returned by php WeChat is garbled?. For more information, please follow other related articles on the PHP Chinese website!