symfony redirect with 2 parameters

后端 未结 6 1016
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-08 07:07

how can i redirect to another action passing 2 or more parameters? this code:

$this->redirect(\'input/new?year=\' . $year . \'&month=\' . $month);
         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-08 07:29

    In the currently supported Symfony versions (2.7+) it's even easier (plus, you can optionally add also the status code at the end):

    return $this->redirectToRoute(
        'default',
        array('year' => $year, 'month' => $month),
        Response::HTTP_MOVED_PERMANENTLY // = 301
    );
    

提交回复
热议问题