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

Jeff picture Jeff · Dec 23, 2009 · Viewed 10k times · Source

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.

Answer

Pekka picture Pekka · Dec 23, 2009

The only small functional difference seems to be that ini_set returns false when it was unable to change the setting and error_reporting always returns the old error level.