M
M
Monitorkin2017-07-12 08:40:18
Yii
Monitorkin, 2017-07-12 08:40:18

How to overwrite the value of a variable in config/params.php from a program?

Hello,
How can I overwrite the value of a variable in config/params.php from a program?
Why Yii::$app->params[ 'test' ] = 'new value'; does not work?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2017-07-12
@webinar

Why Yii::$app->params[ 'test' ] = 'new value'; does not work?

works, do an experiment:
Yii::$app->params[ 'test' ] = 'новое значение'; 
echo Yii::$app->params[ 'test' ]; //выведет  'новое значение'

If it does not display, then write what it outputs and whether there are errors, after including all php errors

D
Dmitry, 2017-07-12
@slo_nik

I do the following: I assign a new value to the test variable like this: Yii::$app->params[ 'test' ] = 'new value'; then I open the config/params.php file and there is the old value...

Here is a hint how to do it. Written for yii1, but easy to convert to yii2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question