Reputation: 545488
Is it possible to set php.ini
values from within PHP? Optimally with a limited scope?
Background: I want to force-allow short_open_tag
for the duration of an include
command to facilitate content writers’ jobs. The actual PHP web application uses long tags throughout (well, one at the beginning and one at the end, really) but for the content files I’d like to enable the more convenient shortcuts.
The content files are then rendered by a combination of output buffering and require
, and the result of this is used to fill out a view-specific template. (I know about template engines such as Smarty but I don’t want to use them here.)
The php.ini
documentation unfortunately doesn’t tell how to query/set the configuration values.
Upvotes: 2
Views: 4506
Reputation: 1165
if you used ini_set able to control php.ini settings programaticaly
ini_set('display_errors', 1);
http://php.net/manual/en/ini.core.php
Upvotes: 1
Reputation: 7981
You can dynamically set some of the PHP configuration variables using ini_set()
: http://php.net/ini_set. Note that not all variables can be changed at run-time, but short_open_tag
can be. See here for more details on what can and can't be changed in which situations: http://php.net/ini.core.php.
Upvotes: 2
Reputation: 37945
Would ini_set do the job ?
string ini_set ( string $varname , string $newvalue )
There's also ini_get for querying the configuration.
Upvotes: 6