What is the recommended error_reporting() setting for development? What about E_STRICT?

前端 未结 8 1533
醉梦人生
醉梦人生 2020-12-06 04:29

Typically I use E_ALL to see anything that PHP might say about my code to try and improve it.

I just noticed a error constant E_STRICT, but

相关标签:
8条回答
  • 2020-12-06 04:43

    ini_set("display_errors","2"); ERROR_REPORTING(E_ALL);

    0 讨论(0)
  • 2020-12-06 04:48

    In my opinion, the higher you set the error reporting level in development phase, the better.

    In a live environment, you want a slightly (but only slightly) reduced set, but you want them logged somewhere that they can't be seen by the user (I prefer syslog).

    http://php.net/error_reporting

    E_ALL | E_STRICT for development with PHP before 5.2.0.

    5.2 introduces E_RECOVERABLE_ERROR and 5.3 introduces E_DEPRECATED and E_USER_DEPRECATED. You'll probably want to turn those on if you're running one of those versions.

    If you wanted to use magic numbers you could just set the error_reporting value to some fairly high value of 2^n-1 - say, 16777215, and that would really just turn on all the bits between 1..n. But I don't think using magic numbers is a good idea...

    In my opinion, PHP has dropped the ball a bit by having E_ALL not really be all. But apparently it's going to be fixed in PHP 6...

    0 讨论(0)
提交回复
热议问题