* URL 重定向
* @access protected
* @param string $url 跳转的 URL 表达式
* @param array|int $params 其它 URL 参数
* @param int $code http code
* @param array $with 隐式传参
* @return void
* @throws HttpResponseException
*/
protected function redirect($url, $params = [], $code = 302, $with = [])
{
if (is_integer($params)) {
$code = $params;
$params = [];
}
$response = new Redirect($url);
$response->code($code)->params($params)->with($with);
throw new HttpResponseException($response);
}
重定向方法redirect,为什么最后一步要用抛异常,如果不这么用,还有没有其他写法?
最佳答案