Recall & Review
beginner
What is strict typing in PHP?
Strict typing means PHP checks the exact data type of variables and function arguments, preventing automatic type conversion.
Click to reveal answer
beginner
How does strict typing help prevent bugs?
It stops unexpected type conversions that can cause errors, making code behavior more predictable and easier to debug.
Click to reveal answer
intermediate
What happens if you pass a string to a function expecting an integer with strict typing enabled?
PHP will throw a TypeError instead of silently converting the string to an integer.
Click to reveal answer
beginner
How do you enable strict typing in a PHP file?
Add declare(strict_types=1); at the very top of the PHP file before any code.
Click to reveal answer
beginner
Why might strict typing improve code readability?
Because it clearly shows what types are expected, making it easier to understand what data a function works with.
Click to reveal answer
What does strict typing prevent in PHP?
✗ Incorrect
Strict typing stops PHP from automatically converting types, enforcing exact data types.
How do you activate strict typing in a PHP file?
✗ Incorrect
You enable strict typing by adding declare(strict_types=1); at the start of the PHP file.
What error occurs if a wrong type is passed with strict typing?
✗ Incorrect
PHP throws a TypeError when a type mismatch happens with strict typing enabled.
Why is strict typing useful for debugging?
✗ Incorrect
Strict typing helps catch type errors early, making debugging easier.
Which of these is a benefit of strict typing?
✗ Incorrect
Strict typing makes code behavior more predictable by enforcing types.
Explain why strict typing matters in PHP and how it affects code reliability.
Think about how PHP treats data types with and without strict typing.
You got /4 concepts.
Describe how to enable strict typing in a PHP file and what happens if a wrong type is passed to a function.
Focus on the syntax and the error behavior.
You got /3 concepts.