dqybeh2884 2014-10-19 11:05
浏览 15
已采纳

当重写具有不同签名的方法时,为什么PHP不显示严格标准错误?

I'm running on PHP Version 5.5.9-1ubuntu4.4

When I run file with code:

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

class A
{
  public function f(array $array)
  {
    echo 'a';
  }
}

class B extends A
{
  public function f(A $a, array $b)
  {
    echo 'b';
  }
}

$a = new A();
$a->f([1, 2, 3]);
$b = new B();
$b->f($a, []);

I'm expecting to get a "Strict Standards" error, because I'm overloading metod with a different signature. But I didn't get any error or any warning message. Just normal output. Why?

  • 写回答

2条回答 默认 最新

  • doutai1509 2014-10-19 11:16
    关注

    It is possible that E_STRICT has been disabled in your php.ini file to supress errors such as this in legacy apps that are somewhat badly written when PHP was not standardised as it is now (though still not very standardised).

    Also, in PHP versions BELOW 5.4.0, E_STRICT is not included in E_ALL. E_STRICT is only included in E_ALL in PHP versions 5.4.0 and above.

    With strict errors, they are usually thrown at "compile time", so are thrown well before error_reporting is called, so would need to be set in php.ini

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题