##跳轉
--
~~~
namespace app\index\controller;
class Index
{
use \traits\controller\Jump;
public function index($name='')
{
if ('thinkphp' == $name) {
$this->success('歡迎使用ThinkPHP
5.0','hello');
} else {
$this->error('錯誤的name','guest');
}
}
public function hello()
{
return 'Hello,ThinkPHP!';
}
public function guest()
{
return 'Hello,Guest!';
}
}
~~~
##直接跳轉
>[info]redirect方法默認使用302跳轉,如不需要可以使用第二個參數進行301跳轉。
~~~
$this->redirect('http://www.baidu.com',301);
~~~