If I added some key-value pairs in the returned array in config/main.php, how can I load value with a given key?
If I added some key-value pairs in the returned array in config/main.php, how can I load value with a given key?
Set the configuration in ‘param’ (like adminEmail in the default skeleton)
so in configMain:
'params'=>array(
// this is used in contact page
'adminEmail'=>'webmaster@example.com',
'myParam'=>'myValue',
),
In your code, wherever you need:
$param=Yii::app()->params['myParam'];
Thank you! I read through the definitive guide and could not find the answer. So usually how to find the answer for this kind of questions?
Posting in the forum…
I am jocking. Just keep in mind that all is defined in main.conf (and all that belongs to CWebApplication) can be accessed in any part of code with Yii::app()