开发者

What do you think that the error_reporting(1); instruction makes? [closed]

开发者_JS百科 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

What do you think that the error_reporting(1); instruction makes?


See the PHP docs:

1 E_ERROR (integer) Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.

Note that whenever constants like this are defined, you should use the named constant over the literal integer.


E_ERROR is defined as 1, so it's the same as

error_reporting(E_ERROR);

So basically it tells PHP only to report fatal errors.

As Skilldrick says, you should use named constants, as their defined values can and will change through newer versions of PHP. One well-known such example is E_ALL, which had the following values (from the same PHP manual table):

  • 30719 in PHP 5.3.x (currently)
  • 6143 in PHP 5.2.x
  • 2047 previously


That would be identical to

 error_reporting(E_ERROR);

From the manual:

Fatal run-time errors. These indicate errors that can not be recovered from, such as a memory allocation problem. Execution of the script is halted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜