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 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败