Why does php only sometimes have a dedicated function for setting an ini parameter?

Viewed 44

To set e.g. error reporting, you can use EITHER error_reporting($X) OR set_ini('error_reporting', $X). But with e.g. error displaying, you can ONLY use set_ini('display_errors', $Y).

Is there any rhyme or reason to predict when a dedicated function will be available to change ini settings, or is it just haphazard historical happenstance?

(I ask because I want to develop a mental model as to when to use one or the other.)

1 Answers

I'd dare to say it's historical happenstance.

PHP has a number of such inconsistencies, part of which are listed on PHP Sadness. After using PHP for a few years now, my experience is that it's best to have a good IDE rather than trying to remember such things. PhpStorm for example has an auto complete for the parameters of ini_set().

In that particular case, stick with ini_set() for consistency because that works for all ini options.

Related