search

Home  >  Q&A  >  body text

php - laravel route parsing error after url encoding of routing parameters

I encode the parameters

$msg = '这是测试 点击 <a href="/new/abc" > 测试 </a> 进行跳转';
$msg = urlencode(base64_encode($msg));
return redirect()->route('test', ['id' => 10, 'msg'=>$msg]);

Route definition

Route::get('/test/{id}/msg/{msg?}', 'TestrController@index')->name('test');

I found that the encoded $msg will cause routing parsing errors. I tested it like this /test/1/msg/balabala No problem

PHP中文网PHP中文网2834 days ago981

reply all(2)I'll reply

  • 習慣沉默

    習慣沉默2017-06-22 11:56:11

    I copied and pasted your code into my project and tested it without error -- Laravel5.4

    reply
    0
  • 大家讲道理

    大家讲道理2017-06-22 11:56:11

    This is a laravel project, what function are you doing? It should be time compensation, right? You can't pass parameters in this way when routing, right? If you explain it in more detail, I think I can help you. I have just done the function of passing multiple parameters. . .

    reply
    0
  • Cancelreply