Yii 学习笔记(二)

http://blog.csdn.net/yjj1s/article/details/5767810

Controller中的setFlash()、hasFlash()、getFlash()的使用。

 

PostController.php

 

class PostController extends CController

{

...

...

public function actionView()

{

 

$this->setFlash('commentSubmitted', '跳转后可以显示的消息');

$this->redirect(array('index'));

}

 

public function actionIndex()

{

$this->render('view');

}

}

 

view.php

 

<?php

if($this->hasFlash('commentSubmitted'))

{

echo $this->getFlash('commentSubmitted');//输出:跳转后可以显示的消息'

}

?>

 

所以这三个方法可以用来传递跳转后的消息,显示在弹出窗口之类的信息。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章