PHP的extends继承关系

废话少说上代码:<?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();

原文地址:https://www.cnblogs.com/web928943/p/12560352.html