TCM
TCM

Reputation: 16920

How to dynamically set directives in php.ini from our php code?

How do we dynamically set directives in php.ini from our code? We were asked this question in our exam. Is this a trick question? I thought we can't set directives directly like that and it requires restarting of Apache server.

Thanks in advance:)

Upvotes: 1

Views: 1255

Answers (1)

Pekka
Pekka

Reputation: 449823

The answer is probably ini_set() that changes a PHP.ini setting for the duration of the current script.

There is no way to change php.ini's settings themselves from within PHP code (except of course some horrible construction that acquires root privileges, alters php.ini, and restarts the server, but that's hardly what the test was about).

Upvotes: 2

Related Questions