Error reporting on in PHP code vs. ini file

right now i’m in development. most sources i read recommend controlling error reporting with code like this in a config file:


if(DEBUG == true)
{
    ini_set('display_errors', 'On');
    error_reporting(E_ALL);
}
else
{
    ini_set('display_errors', 'Off');
    error_reporting(0);
}

but why wouldn’t I just update the ini file to match the error reporting i wanted? is there an advantage of one way over the other?

Thanks

Generally so that you are not affecting other projects that may reside on the same server (using the same config file).

Side note and sort of self promotion, have a look at https://github.com/KyleWolfe/PHPErrorNet. A controversial topic, but like it or not, PHP is far looser than other languages. I recommend tightening it up, and force yourself to write better code. This project also gives you an easy way to have centralized reporting on those exceptions / errors (email, logging, etc)