Intermediate PHP
Q44 / 100

What is dependency injection in PHP?

Correct! Well done.

Incorrect.

The correct answer is B) Providing a class's dependencies from outside rather than having the class create them, improving testability

B

Correct Answer

Providing a class's dependencies from outside rather than having the class create them, improving testability

Explanation

DI passes dependencies (e.g., a database connection) via constructors or methods instead of using new inside the class, enabling mocking in tests.

Progress
44/100