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');//輸出:跳轉後可以顯示的消息'

}

?>

 

所以這三個方法可以用來傳遞跳轉後的消息,顯示在彈出窗口之類的信息。

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