糯米文學吧

位置:首頁 > 計算機 > php語言

ThinkPHP中redirect用法實例分析

php語言2.28W

ThinkPHP中redirect如何使用,下面是小編給大家提供的ThinkPHP中redirect用法實例分析,大家可以參考閲讀,更多詳情請關注應屆畢業生考試網。

ThinkPHP中redirect用法實例分析

redirect 重定向的.通用語法為:redirect(url,params=array(),delay=0,msg=''),假設當前為默認 HOME分組 Aritcle模塊 insert操作,一些例子如下:

代碼如下:

// 跳轉到 edit 操作

$this->redirect('edit');

// 跳轉到 UserAction下的edit 操作

$this->redirect('User/edit');

// 跳轉到 Admin分組默認模塊默認操作

$this->redirect('Admin/');

// 跳轉到 Admin分組Index模塊view操作

$this->redirect('Admin-Index/view');

// 跳轉到 Admin分組Index模塊view操作,uid參數為1,延遲3秒跳轉

$this->redirect('Admin-Index/view', array('uid'=>1), 3,'頁面跳轉中~')

// 跳轉到 其他OtherApp項目(非分組)的Admin項目分組User模塊view操作

$this->redirect('OtherApp://Admin-User/view');

同項目分組中的URL訪問一樣,redirect 中跨分組跳轉只是多了一個分組項目名稱的概念.

提示:可以在 redirect 中使用路由,redirect 方法的參數用法和 U函數 的用法一致.可參考 U函數 生成URL地址相關部分內容.

希望本文所述對大家基於ThinkPHP的PHP程序設計有所幫助。