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)
{
}
代码如上,问题是
$this->logger("R ".$postStr);
$this->logger("T ".$result);
这两行代码的作用是?
//写日志,参数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);
}
百度看到了这个...这个看懂了点,但是我之前那个logger方法是空的也有用吗?
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)
{
}
代码如上,问题是
$this->logger("R ".$postStr);
$this->logger("T ".$result);
这两行代码的作用是?
//写日志,参数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);
}
百度看到了这个...这个看懂了点,但是我之前那个logger方法是空的也有用吗?
打印日志记录啊