how I add flash message to my site using related controller please explain step by step i'm new to the php.
I use yii2 framework to build the site and i need to print flash message in the index page using create controller.
Currently the question is too broad, but here is basic usage:
1) You can set in controller like that:
\Yii::$app->session->setFlash('flashMessage', 'Hello world!');
2) Then you can display it in view like so:
echo \Yii::$app->session->getFlash('flashMessage');
Optionally you can check the existence with:
\Yii::$app->session->hasFlash('flashMessage');
Official docs:
There are actually more methods for working with flashes, you can see it in official docs.
Also advanced template provides useful widget Alert that integrated with Boostrap 3:
\Yii::$app->session->setFlash('error', 'This is the error message');
...
echo Alert::widget();
For better understanding of working with flash messages, go through @ http://www.yiiframework.com. By following this method, you can done printing flash messages in your web page.