首先声明,这是一个STRICT错误,如果你不在error_reporting里把它打开,一般是看不到的,以下是我的代码
<?php
class A
{
private function test($a, $b, $c)
{
echo 'test';
}
}
class B extends A
{
private function test($d)
{
echo 'hello';
}
}
new B();
它会报错
Strict Standards: Declaration of B::test() should be compatible with that of A::test() in /home/work/test.php on line 17
如果是public函数重载还能说的过去,而我只是在私有函数中使用了同名的方法,但是对于子类来说这并不算是重载吧,为什么这样还会报警告呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
贴个链接:http://stackoverflow.com/questions/31...
在种情况下,STRICT模式要求:
1.access level 相同
2.参数 相同
3.默认参数值 相同