PHP Laravel MCQ Questions & Answers
This section focuses on "Laravel" PHP Framework. These Multiple Choice Questions (MCQ) should be practiced to improve the PHP Laravel skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Which of the following is true about Laravel?
A. Laravel is an open-source PHP framework
B. Laravel is robust
C. Laravel is easy to understand
D. All of the above
View Answer
Ans : D
Explanation: Laravel is an open-source PHP framework, which is robust and easy to understand.
2. ORM (Object Relational Mapper) and ActiveRecord implementation called?
A. Eloquent
B. Query Builder
C. Schema Builder
D. Blade Template
View Answer
Ans : A
Explanation: ORM (Object Relational Mapper) and ActiveRecord implementation called Eloquent.
3. ______________ acts as a bridge between a request and a response.
A. Routing
B. Middleware
C. Namespaces
D. Request
View Answer
Ans : B
Explanation: Middleware acts as a bridge between a request and a response.
4. How many types of Middleware in Laravel?
A. 2
B. 3
C. 4
D. 5
View Answer
Ans : A
Explanation: There are two types of Middleware in Laravel : Global Middleware and Route Middleware.
5. ________________ can be defined as a class of elements in which each element has a unique name to that associated class.
A. Routing
B. Cookie
C. Namespaces
D. Request
View Answer
Ans : C
Explanation: Namespaces can be defined as a class of elements in which each element has a unique name to that associated class.
6. In the MVC framework, the letter 'C' stands for?
A. Cookie
B. Configuration
C. command prompt
D. Controller
View Answer
Ans : D
Explanation: In the MVC framework, the letter ‘C’ stands for Controller. It acts as a directing traffic between Views and Models. In this chapter, you will learn about Controllers in Laravel.
7. Cookie can be created by global cookie helper of Laravel.
A. TRUE
B. FALSE
C. Can be true or false
D. Can not say
View Answer
Ans : A
Explanation: Cookie can be created by global cookie helper of Laravel. It is an instance of SymfonyComponentHttpFoundationCookie.
8. How many arguments cookie() method will take?
A. 2
B. 4
C. 1
D. 3
View Answer
Ans : D
Explanation: Cookie() method will take 3 arguments. First argument is the name of the cookie, second argument is the value of the cookie and the third argument is the duration of the cookie after which the cookie will get deleted automatically.
9. Which method will automatically convert the array into appropriate json response?
A. application.json
B. json
C. routes
D. test
View Answer
Ans : B
Explanation: JSON response can be sent using the json method. This method will automatically set the Content-Type header to application/json. The json method will automatically convert the array into appropriate json response.
10. Which version introduces the concept of using Blade?
A. Laravel 2.1
B. Laravel 3.1
C. Laravel 4.1
D. Laravel 5.1
View Answer
Ans : D
Explanation: Laravel 5.1 introduces the concept of using Blade, a templating engine to design a unique layout.
Discussion