Quiz Sagar...
Menu

Top Laravel, PHP & Database Interview Questions and Answers

Which superglobal variable in PHP is used to collect data sent via an HTTP POST request?

  • $_GET
  • $_POST
  • $_REQUEST
  • $_SERVER
  • None of the above
  • option2
  • Clear All
Clear All

Which Artisan command is used to execute database migrations in Laravel?

  • php artisan migrate
  • php artisan db:migrate
  • php artisan make:migration
  • php artisan run:migration
  • option1
  • Clear All
Clear All

Which SQL clause is used to filter aggregated results after a GROUP BY clause?

  • WHERE
  • HAVING
  • ORDER BY
  • FILTER BY
  • option2
  • Clear All
Clear All

Which of the following features were introduced in PHP 8.0 or later? (Select all that apply)

Ans. - option1,option2,option3,option4
Clear All

Which Eloquent method in Laravel defines a One-to-Many relationship?

  • hasOne()
  • hasMany()
  • belongsTo()
  • belongsToMany()
  • option2
  • Clear All
Clear All

What is the primary function of a Database Index?

  • To encrypt sensitive table data
  • To speed up data retrieval operations on a database table
  • To automatically enforce foreign key constraints
  • To create automatic database backups
  • option2
  • Clear All
Clear All

Does PHP support multiple inheritance for classes natively?

  • Yes
  • No
  • option2
  • Clear All
Clear All

Which component in Laravel is responsible for managing class dependencies and performing dependency injection?

  • Service Container
  • Artisan CLI
  • Blade Engine
  • Eloquent ORM
  • option1
  • Clear All
Clear All

Which of the following are part of the ACID properties in relational database transactions? (Select all that apply)

Ans. - option1,option2,option3,option4
Clear All

What is the result of evaluating `5 + '10'` in PHP due to type coercion?

  • '510'
  • 15
  • TypeError exception
  • 510
  • option2
  • Clear All
Clear All

Which default middleware in Laravel is used to protect application routes against CSRF attacks?

  • ValidateSignature
  • VerifyCsrfToken
  • Authenticate
  • EncryptCookies
  • option2
  • Clear All
Clear All

Which SQL JOIN type returns all records when there is a match in either left or right table records?

  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL OUTER JOIN
  • option4
  • Clear All
Clear All

What is the primary purpose of Traits in PHP?

  • To enable horizontal code reuse across independent classes
  • To store global environment configurations
  • To compile PHP scripts into executable binary files
  • To eliminate the need for database migrations
  • option1
  • Clear All
Clear All

Which issue in database querying does Eloquent eager loading (`with()`) directly prevent?

  • SQL Injection vulnerability
  • The N+1 query performance issue
  • Database deadlock condition
  • Memory leak in PHP session
  • option2
  • Clear All
Clear All

Which Artisan command generates a new controller class in a Laravel project?

Ans. - php artisan make:controller ControllerName
Clear All