LARAVEL Routing MCQ
Laravel MCQ(1) Which of the following route can be used to catch all http requests in place of 404.
A) Route::all(
B) Route::last(
C) Route::fallback
D) Route::404(
Explanation
Route::fallback is a type of dynamic route, that can be used to catch every http request. In case of no one route matched. By default these requests are direct to 404 by Laravel default exception handling.
(2) In Laravel which of the following route is used to match all HTTP verbs?
A) Route::take
B) Route::any
C) Route::match
D) Route::all
Explanation
Route::any is used to match all HTTP verbs for particular URI. This route is helpful where we are required to implement multiple http requests against single URI. Alternatively we can also use Route::match but here we will have to provide names of all HTTP verbs as array.
(3) Which of the following dynamic route is used to specify more than one HTTP verbs in a single route ?
A) Route::match
B) Route::any
C) Route::catch
D) Fallback
Explanation
Route::match route is used to match multiple HTTP requests in a single route. Multiple HTTP verbs can be provided as an array in this route as first parameter. Such as:
Route::match(['get','post'], '/URI', 'MyController@controllerMyMethod');
(4) In which of the following HTTP request parameters are displayed in URL?
A) GET
B) POST
C) Both
D) None
Explanation
In get request passed parameters are displayed in URL.
(5) Which of the following HTTP verb is not available in Laravel application?
A) get
B) post
C) catch
D) patch
Explanation
Cath is not a HTTP verb and this is not available to implement in laravel application. All other available options are valid HTTP verbs.