Home  >  Article  >  Backend Development  >  继承问题

继承问题

WBOY
WBOYOriginal
2016-06-23 13:25:58876browse

Declaration of Sh::a() should be compatible with Base::a($key, $value)
在Sh类里定义了一个a()方法,Sh类继承Base类,Base里也定义有一个a()方法,实例化Sh类的时候就报了上面的错误


回复讨论(解决方案)

Sh::a 与 Base::a 的参数个数不一致

这是 Strict Standards 错误,php5.3 引入
php5.4 开始默认检查,不可在程序中屏蔽,但可在 php.ini 中给 
error_reporting 附加 ^ E_STRICT 屏蔽

你是改写了base类的a方法
base类 a方法有两个参数$key, $value
而Sh类的a方法没有参数,所以会出这个警告

在Sh的a方法中加入这两个参数就可以了
Sh::a($key, $value);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn