如何解决php微信输出乱码
2542
php微信输出乱码的解决办法:1、使用urlencode进行编码;2、通过“urldecode(json_encode($message));”方式转换编码即可。
如何解决php 微信输出乱码?
PHP微信发送推送消息乱码的解决方法
先用urlencode是因为中文在数组转json时会被编码为unicode,微信接口无法识别,所以得在json_encode前先来个编码,等转换后再用urldecode转回来,这样传输给接口的就是正常的中文了。
参考代码:
- $message = array(
- 'touser'=>$touser,
- 'msgtype'=>'text',
- 'text'=>array('content'=>urlencode($text))
- );
- $message = urldecode(json_encode($message));
本文网址:https://www.zztuku.com/index.php/detail-10358.html
站长图库 - 如何解决php微信输出乱码
申明:如有侵犯,请 联系我们 删除。
您还没有登录,请 登录 后发表评论!
提示:请勿发布广告垃圾评论,否则封号处理!!