YII 控制器的呼叫,在其它控制器中
阿新 • • 發佈:2018-11-17
分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow
也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!
一個contoller CustomerController裡怎麼呼叫另一個controller裡的action,Acontoller呼叫SiteContoller的actionShow($id), url顯示上是Customer/index$control=Yii::app()->runController('site/show/id/2');
不帶引數的actionShow()
$control=Yii::app()->runController('site/show');
redirect使用方法
$this->redirect(array('/site/contact','id'=>12));
//http://www.localyii.com/testwebap/index.php?r=site/contact&id=12
$this->redirect(array('site/contact','id'=>'idv','name'=>'namev'));
//http://www.localyii.com/testwebap/index.php?r=site/contact&id=idv&name=namev
$this->redirect(array('site/contact','v1','v2','v3'));
//http://www.localyii.com/testwebap/index.php?r=site/contact&0=v1&1=v2&2=v3
$this->redirect(array('site/contact','v1','v2','v3','#'=>'ttt'));
//帶anchor的 http://www.localyii.com/testwebap/index.php?r=site/contact&0=v1&1=v2&2=v3#ttt
跳轉到一個絕對路徑
$this->redirect('http://www.baidu.com');