天天看點

YII contoller之間的方法調用 redirect

一個contoller customercontroller裡怎麼調用另一個controller裡的action,acontoller調用sitecontoller的actionshow($id), url顯示上是customer/index

YII contoller之間的方法調用 redirect

$control=yii::app()->runcontroller('site/show/id/2');  

不帶參數的actionshow()

YII contoller之間的方法調用 redirect

$control=yii::app()->runcontroller('site/show');  

redirect使用方法

YII contoller之間的方法調用 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  

 跳轉到一個絕對路徑

YII contoller之間的方法調用 redirect

$this->redirect('http://www.baidu.com');