天天看點

YII2.0 中URL跳轉

不帶參數跳轉到views/index.php

return $this ->renderPartial( 'index.php');

帶參數跳轉到 views/index.php

$hello ='hello world!';

return $this -> renderPartial( 'index.php' ,['hello'=> $hello] );

帶參數跳轉到 views/index.php,參數是數組

$hello =array( 1,2);

return $this -> renderPartial( 'index.php' ,['hello'=> $hello] );

将視圖替換 $content變量放到layout檔案中然後跳轉到 views/index.php

public $layout ='Common';

return $this ->render( 'index');

在視圖中加載另外一個視圖

<?=$this ->render( 'about',['hello' =>$hello]) ?>

不帶參數跳轉到另一個action

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

帶參數跳轉到另一個action