How to use constant variables in Yii

Yii

Posted on 16 Apr 15 by Vickey
  955



In Yii we can define our constant in /config/params.php file

return [
    'adminEmail'        => 'admin@example.com',
    'application_name'  => 'My App',
];

and in our views an controller we can access these by using

Yii::app()->params['application_name'];  // in yii 1

Yii::$app->params['application_name']; // in yii 2

If this post help you reduce time to develop, you can help me to maintain this website :)
www.000webhost.com