Professional Documents
Culture Documents
MCQ 3 Laravel
MCQ 3 Laravel
MCQ 3 Laravel
• average()
• avg()
• median()
• avg_val()
Cancel
View Answer
View Answer
• clear-compiled
• clear compiled
• compiled:clear
• clear:all
View Answer
clear-compiled
Syntax:
php artisan clear-compiled
4. Which method breaks the collection into multiple, smaller collections of a given size
• split()
• chunk()
• explode()
• break()
View Answer
chunk() method in Laravel is used to breaks the collection into multiple, smaller collections of a
given size.
syntax:
$collection = collect([1, 2, 3, 4, 5, 6, 7]);
$chunks = $collection->chunk(4);
$chunks->toArray();
// [[1, 2, 3, 4], [5, 6, 7]]
• cache:flush
• cache:clear
• cache:forget
• cache:remove
View Answer
cache:clear
View Answer
The vendor directory of Laravel contains Third-party code.
• app/Http/
• routes/
• urls/
• vendors/
View Answer
Routing file located in Laravel are location in routes directory.
• .blade.php
• .php
• .vue
• .blade
View Answer
View files in Laravel end in .blade.php
• storage:link
• link:public
• link:storage
• storage:link public/storage
View Answer
storage:link is used to create a symbolic link from "public/storage" directory to
"storage/app/public".
View Answer
View Answer
For setting environment variables
12. Which directory contain “robot.txt” file ?
• app
• public
• config
• storage
View Answer
public
• compact
• {{}}
• helpers
View Answer
{{}}
14. What is the HTTP Status Code for your website. When it is down for maintenance.
• 501
• 200
• 400
• 503
View Answer
503 is HTTP Status Code for your website when it is down for maintenance using artisan down
command
• Printing value
• For string translation
View Answer
• config.php
• setting.php
• In seed files
• .ENV file
View Answer
.ENV file
17. What is the minimum PHP version required to install Laravel 5.3?
• 7.1
• 5.6.4
• 5.3.2
• 5.4.3
View Answer
5.6.4
• $request->db->session('key', 'value');
• $request->session()->set('key', 'value');
• $request->session()->put('key', 'value');
• None of These
View Answer
$request->session()->put('key', 'value');
• Rasmus Lerdorf
• Taylor Otwell
• James Gosling
• Guido van Rossum
View Answer
Taylor Otwell
View Answer
php artisan make:controller --plain
View Answer
It stores classes that provide various services to the rest of the application
View Answer
It stores environment-specific configuration for the application
• $db
• $app
• $cache
• $request
View Answer
$request
View Answer
By adding a new route to the routes/web.php file
View Answer
Both A and B options are right
a) get()
b) post()
c) handle()
d) route()
Answer: d) route()
Answer: b) Route parameters are enclosed in curly braces {} in the route definition.
Q4. How can you access route parameters in a Laravel controller method?
a) response()->json()
b) json()->response()
d) return json_response()
Answer: a) response()->json()
Q6. How can you redirect the user to a different URL in Laravel?
Q7. Which of the following middleware is used to verify if a user is authenticated in Laravel?
a) auth
b) web
c) middleware
d) guest
Answer: a) auth
Answer: b) To verify that the request is not a cross-site request forgery (CSRF)
Q2. How can you access a route parameter value inside a route closure or controller method in
Laravel?
a) view()
b) loadView()
c) render()
d) make()
Answer: a) view()
a) response()->json()
b) json()->response()
Answer: a) response()->json()
Q9. How can you redirect the user to a different URL in Laravel?
UNIT:3
Q1. What is the purpose of a controller in Laravel?
a) To handle database operations.
b) To render views in the browser.
c) To define routes and handle HTTP requests.
d) To manage authentication and authorization.
Answer: c) view()
Answer: a) Route::fallback()
Answer: b) app/Http/Controllers
Q8. How can you extend a Blade template from another
template?
a) By using the @extends() directive.
b) By using the @include() directive.
c) By using the @yield() directive.
d) By using the @extend() directive.