Laravel & PHP Flashcards

1
Q

What are variables in PHP?

A

Variables store data, and PHP supports various data types, including integers, floats, strings, arrays, and objects.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are control structures in PHP?

A

Control structures include conditional statements (if, else, switch) for decision-making and loops (for, while, foreach) for iterating through data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are functions in PHP?

A

Functions are blocks of code that perform a specific task, defined using the function keyword. They can accept parameters and return values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are superglobals in PHP?

A

Superglobals are built-in variables like $_GET, $_POST, $_SESSION, $_COOKIE, etc., used to access global data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is file handling in PHP?

A

File handling involves functions for reading from and writing to files, such as fopen(), fread(), fwrite(), and fclose().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How is error handling done in PHP?

A

Error handling is done using try, catch, and throw for managing exceptions and handling errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is MVC architecture in Laravel?

A

Laravel follows the Model-View-Controller pattern, separating the application logic (Model), user interface (View), and user input (Controller).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How does routing work in Laravel?

A

Laravel uses a simple routing system to define URL routes in the web.php file, linking URLs to specific controller actions.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Eloquent ORM in Laravel?

A

Eloquent ORM is an Object-Relational Mapping system that simplifies database interactions, allowing you to work with databases using PHP syntax instead of SQL.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Blade templating in Laravel?

A

Blade is Laravel’s templating engine that enables dynamic content rendering with an easy-to-use syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is middleware in Laravel?

A

Middleware consists of functions that run before or after requests, used for tasks like authentication and logging.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Artisan CLI in Laravel?

A

Artisan CLI is a command-line interface for running tasks like migrations, creating controllers, and more.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are classes and objects in OOP?

A

A class is a blueprint for creating objects (instances). An object is an instance of a class that can contain properties and methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is encapsulation in OOP?

A

Encapsulation is bundling data (properties) and methods that operate on the data within a class, restricting access to some components.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is inheritance in OOP?

A

Inheritance is a mechanism where a new class (subclass) inherits properties and methods from an existing class (superclass), promoting code reusability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is polymorphism in OOP?

A

Polymorphism is the ability to use a single interface to represent different data types. For example, method overriding allows subclasses to provide a specific implementation of a method defined in the superclass.

17
Q

What is abstraction in OOP?

A

Abstraction is hiding complex implementation details and showing only the essential features of an object. This can be achieved using abstract classes and interfaces.

18
Q

What is the difference between == and === in PHP?

A

== checks for value equality, while === checks for value and type equality.

19
Q

What is the purpose of Composer in Laravel?

A

Composer is a dependency manager for PHP that helps manage libraries and packages in Laravel.

20
Q

How do you handle database migrations in Laravel?

A

Database migrations in Laravel are handled using Artisan commands to create and manage schema changes.

21
Q

Can you explain the concept of a trait in PHP?

A

A trait is a mechanism for code reuse in single inheritance languages, allowing you to include methods in multiple classes.

22
Q

What are access modifiers in OOP?

A

Access modifiers define the visibility of class properties and methods, commonly including public, private, and protected.

23
Q

How does PHP’s garbage collector work?

A

PHP uses a reference counting mechanism to manage memory. If an object’s reference count is 0, it is eligible for garbage collection. PHP has a cycle collector that detects circular references to free memory.

24
Q

What are the different types of PHP errors?

A
  1. Notice - minor errors (undefined variables)
  2. Warning - non-fatal errors (including a non-existent file)
  3. Fatal - critical errors that stop execution (calling a function that doesn’t exist)
  4. Parse - syntax errors
25
Q

Explain the purpose of spl_autoload_register().

A

It allows dynamic class loading, removing the need for multiple require or include statements.

26
Q

What are traits in PHP, and how do they differ from abstract classes?

A

Traits allow code reuse across multiple classes, without inheritance. Unlike abstract classes, traits cannot have constructors and don’t force implementation.