Alex Rivera | Logout

Difference between error_reporting() and ini_set('error_reporting')?

Asked 2009-12-23T20:19:09.860
15

When using error_reporting() or ini_set('error_reporting') in my scripts, are there any functionality differences between the two? Is one method preferred over the other?

For what it's worth, I see many frameworks using error_reporting(), but both options appear to be set during runtime only, then reset back to their default in php.ini after script execution.

Edit
Report

1 Answer

8

"Two roads leading you to Rome": ini_set('error_reporting', ) overrides the parameter set in the php.ini file. error_reporting() receives level number or level id

error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

Both options take effect until the script ends its execution. The next one will use the params defined in the .ini, again.

answered 2009-12-23T20:32:28.410

Your Answer