I'm getting a weird bug in Laravel while using a GET request. I'm performing a get request via javascript like so:
window.location = "messages/clone?id=" + anchorID + '&name=' + newMessageName;
And I'm using a dd($request)
right away inside the controller. The desired behavior would be
Request->request->parameters: array:2[
'id' => 'value'
'name' => 'value'
]
Yet I'm having this output:
Request->request->parameters: array:2[
'?id' => 'value'
'name' => 'value'
]
You'll notice that there's an extra '?' sign right before the 'id'. I'm wondering what's the cause of this?
Thanks in advance, Alex
The parameters that you are dumping are arguments of Route::get()
method. '?'`s mean is the parameter is nullable.
If you want to access get parameters you should use:
$request->query('id');
read more here : https://laravel.com/docs/5.8/requests
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.