废话少说上代码:<?php 

Class Notify{

protected $color = "red"; //子类也可以继承属性
public function message(){ return '<span style="color:'.$this->color.'">发送通知消息</span>'; } } Class User extends Notify { public function register(){ return $this->message(); }
}

Class Comment extends Notify{

public function send()
{

return $this->message();

}

}

echo (new Comment)->send();

 

posted on 2020-03-25 17:03  易博奕-YBYsuccess  阅读(168)  评论(0)    收藏  举报