Programming Languages PHP Objective
Sep 23, 2025

What is the purpose of the declare(strict_types=1) directive?

Choose the correct answer:
A) Enables strict error reporting
B) Enforces strict type checking for function parameters
C) Prevents type juggling
D) All of the above
Detailed Explanation

Explanation: declare(strict_types=1) enforces strict type checking for function parameters and return types in the current file. It prevents automatic type coercion and throws TypeError for type mismatches.

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback