Larvel Mcqs
Larvel Mcqs
1.
What is the purpose of a migration in Laravel?
To create a new database table
窗体底端
窗体顶端
2.
What is the purpose of a migration in Laravel?
To create a new database table
窗体底端
窗体顶端
3.
How do you create a new migration that modifies an existing table
in Laravel?
php artisan make:migration modify_table_name
窗体底端
窗体顶端
4.
Which of the following is used to retrieve all records from a
database table using Laravel's query builder?
DB::all()
DB::get()
DB::find()
DB::first()
窗体底端
窗体顶端
5.
Which of the following is used to define a custom validation rule in
Laravel?
customRule()
addRule()
Rule::add()
Rule::exists()
窗体底端
窗体顶端
6.
What does the return statement do in a PHP function?
It terminates the function.
窗体底端
窗体顶端
7.
What is the purpose of a function parameter in PHP?
To return a value from the function.
窗体底端
窗体顶端
8.
What is recursion in PHP?
A function that returns a value.
窗体底端
窗体顶端
9.
Which of the following loops executes a block of code as long as a
specified condition is true?
While loop
Do-while loop
For loop
Foreach loop
窗体底端
窗体顶端
10.
Which of the following loops executes a block of code at least once,
even if the specified condition is false?
While loop
Do-while loop
For loop
Foreach loop
窗体底端
窗体顶端
11.
What is the syntax for a do-while loop in PHP?
while (condition) { code to be executed; }
窗体底端
窗体顶端
12.
Which symbol is used to start a single-line comment in PHP?
//
窗体底端
窗体顶端
13.
Which symbol is used to concatenate two strings in PHP?
+
&
窗体底端
窗体顶端
14.
What is the default scope of a variable in PHP?
Global
Local
Private
Protected
窗体底端
窗体顶端
15.
Which of the following methods is used to retrieve all rows from a table in Laravel's Query
Builder?
get()
all()
select()
fetch()
窗体底端
窗体顶端
16.
Which of the following methods is used to insert a new record into a table in Laravel's
Eloquent ORM?
save()
insert()
create()
add()
窗体底端
窗体顶端
17.
What is the default namespace for controllers in Laravel?
App\Http\Controllers
App\Controllers
Http\Controllers
Controllers
窗体底端
窗体顶端
18.
What is the purpose of a resource controller in Laravel?
To handle CRUD operations for a model
窗体底端
窗体顶端
19.
Which PHP version is required for Laravel 8?
PHP 5.6.4 or higher
窗体底端
窗体顶端
20.
Which command is used to start the Laravel development server?
php artisan server
php server
php start
artisan serve
窗体底端
窗体顶端
21.
Which directory contains the application's models, controllers, and views in Laravel?
config/
app/
resources/
routes/
窗体底端
窗体顶端
22.
How do you access a specific value in an index array?
By using the key
窗体底端
窗体顶端
23.
Which of the following functions is used to sort an index array in ascending order?
ksort()
rsort()
sort()
asort()
窗体底端
窗体顶端
24.
What is the purpose of the break statement in a switch statement?
to stop the execution of the code in the switch statement
25.
Which of the following statements is used to execute a block of code if a specified condition
is false?
if statement
else statement
switch statement
for statement
窗体底端
窗体顶端
26.
Which extension is used for PHP files?
.html
.js
.php
.css
窗体底端