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.