Laravel get request parameters: request() vs $request->input()
Contents

There are many ways to get the request parameters in Laravel, such as request(), $request->input(), $request->get(),
but there are a little different between request() and $request->input() when the parameter is not actually passed.
Sometimes it maybe cause some unexpected behavior, Let’s see:
 | 
 | 
When our request like this: http://localhost/test?key=, yes, we do not actually set a value for the key, the output will be:
 | 
 | 
Interesting, right?
Author
LastMod 2024-06-29