There is a problem in the development of WeChat, $this->logger ("R". $postStr);

Source: Internet
Author: User
Keywords PHP Micro-mail
public function responseMsg()    {        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];//保留xml类型原始数据        if (!empty($postStr)){            $this->logger("R ".$postStr);                        $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);//把数据载入到对象postObj中            $RX_TYPE = trim($postObj->MsgType);//调用对象postObj里的MsgType            switch ($RX_TYPE)            {                case "event":                    $result = $this->receiveEvent($postObj);                    break;                case "text":                    $result = $this->receiveText($postObj);                    break;            }            $this->logger("T ".$result);            echo $result;        }    }
private function logger($log_content)    {    }

Code as above, the problem is
$this->logger ("R". $postStr);
$this->logger ("T". $result);
What do these two lines of code do?

//写日志,参数log_content传日志的内容    private function logger($log_content){        //日志大小 1000KB        echo "6";        $max_size = 1000;        $log_filename = "log.xml";                if(file_exists($log_filename) && (abs(filesize($log_filename)) > $max_size)){            unlink($log_filename);        }                file_put_contents($log_filename,date("H:i:s")." ".$log_content."\n",FILE_APPEND);    }

Baidu saw this ... This is a little bit, but my previous logger method is empty and useful?

Reply content:

public function responseMsg()    {        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];//保留xml类型原始数据        if (!empty($postStr)){            $this->logger("R ".$postStr);                        $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);//把数据载入到对象postObj中            $RX_TYPE = trim($postObj->MsgType);//调用对象postObj里的MsgType            switch ($RX_TYPE)            {                case "event":                    $result = $this->receiveEvent($postObj);                    break;                case "text":                    $result = $this->receiveText($postObj);                    break;            }            $this->logger("T ".$result);            echo $result;        }    }
private function logger($log_content)    {    }

Code as above, the problem is
$this->logger ("R". $postStr);
$this->logger ("T". $result);
What do these two lines of code do?

//写日志,参数log_content传日志的内容    private function logger($log_content){        //日志大小 1000KB        echo "6";        $max_size = 1000;        $log_filename = "log.xml";                if(file_exists($log_filename) && (abs(filesize($log_filename)) > $max_size)){            unlink($log_filename);        }                file_put_contents($log_filename,date("H:i:s")." ".$log_content."\n",FILE_APPEND);    }

Baidu saw this ... This is a little bit, but my previous logger method is empty and useful?

Print log records.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.