B
B
BonBon Slick2017-01-20 16:47:07
Laravel
BonBon Slick, 2017-01-20 16:47:07

Difference of 2 entries $request->input and $request->get('input') if the results are the same?

Laravel 5.3, what's the difference if the result is the same?
The second option is longer, more visual load, and it's kind of like an additional method on the collection, which means additional operation execution time.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Kudinov, 2017-01-26
@BonBonSlick

$request->get('input')- a direct legacy from SymfonyRequest
$request->input - already implemented in Laravel with the help of magic ( __get('input') ) and has a different implementation independent of $request->get().
$request->get('input')and $request->inputmay return different results under certain conditions. The second option will return the value where the first one returns null, but a little "slower".
You can see the implementation of each of them on GitHub:
SymfonyRequest::get()
Request::__get()

R
Roman, 2017-01-26
@GUY

1) there can be a conversion or protection in this method
2) the recommendations say to use the set and get methods instead of direct access

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question