关于微信接收事件推送读取数据库中文乱码问题

代码中省略数据库部分!

header('content-type:text/html;charset=utf-8');
if( strtolower( $postObj->MsgType) == 'text'){
     if (!$rows){
         $template  = "<xml>
                          <ToUserName><![CDATA[%s]]></ToUserName>
                          <FromUserName><![CDATA[%s]]></FromUserName>
                          <CreateTime>%s</CreateTime>
                          <MsgType><![CDATA[%s]]></MsgType>
                          <Content><![CDATA[%s]]></Content>
                          </xml>";
            $fromUser=$postObj->ToUserName;
            $toUser=$postObj->FromUserName;
            $time=time();
            $content='暂无收货人手机号为:'.$sphone.'的订单信息';
            $msgType='text';
            echo sprintf($template,$toUser,$fromUser,$time,$msgType,$content);
     }else {
     $fname=$rows['fname'];
         $template  = "<xml>
                          <ToUserName><![CDATA[%s]]></ToUserName>
                          <FromUserName><![CDATA[%s]]></FromUserName>
                          <CreateTime>%s</CreateTime>
                          <MsgType><![CDATA[%s]]></MsgType>
                          <Content><![CDATA[%s]]></Content>
                          </xml>";
            $fromUser=$postObj->ToUserName;
            $toUser=$postObj->FromUserName;
            $time=time();
            $content='发货人:'.$fname;
            $msgType='text';
            echo sprintf($template,$toUser,$fromUser,$time,$msgType,$content);
     }
         }

为什么接收的值为"发货人:??",如何解决,谢谢!

homedevise
浏览 2244回答 2
2回答

雪颲

我能说那个$content那里分号写错了吗,是中文的分号
打开App,查看更多内容
随时随地看视频慕课网APP