该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
按照实例,我想想封装下,怎么调试都失败。请帮忙看看哪里错了。
1.index.php
require_once 'util/MessageUtil.php';
if("0" == $this->keyword){
$message = transmitService($object);
return $message;
}
2.MessageUtil.php
require_once 'TransMessage.php';
class MessageUtil {
/**
* 多客服消息
*/
public function transmitService($toUsername, $fromUsername){
$TransMessage = new TransMessage($toUsername,$fromUsername);
echo $TransMessage->getMessage();
}
}
3.TransMessage.php
class TransMessage extends AbstractBaseMessage{
/**
* transfer_customer_service
*/
protected function getMessageType() {
return "transfer_customer_service" ;
}
}
5.AbstractBaseMessage.php
/**
* 回复消息基类
* @author Administrator
*
*/
abstract class AbstractBaseMessage {
protected $message;
protected $fromUsername;
protected $toUsername ;
protected $time ;
/**
* 获取消息模板
*/
protected abstract function getMessageContent();
/**
*
* @param unknown_type $fromUsername 消息发送者
* @param unknown_type $toUsername 消息接收者
*/
public function __construct($toUsername,$fromUsername){
$this->time = time();
$this->fromUsername = $fromUsername;
$this->toUsername = $toUsername;
// echo "父类方法1..\n".$this->toUsername;
}
public function getMessage() {
$messageType = $this->getMessageType();
$tpl_header = "
toUsername}]]>
fromUsername}]]>
{$this->time}
";
$tpl_footer = "";
$this->message = $tpl_header.$this->getMessageContent().$tpl_footer;
return $this->message;
}
protected abstract function getMessageType();
}
上传到服务器,总是触发不了 transfer_customer_service