Recall & Review
beginner
What is type awareness in programming?
Type awareness means knowing and using the correct data types (like numbers, text, or true/false) in your code to avoid mistakes and make your program work as expected.
Click to reveal answer
beginner
Why does PHP benefit from type awareness?
PHP is flexible with types but being aware helps catch errors early, improves code clarity, and makes programs more reliable and easier to maintain.
Click to reveal answer
beginner
What can happen if you ignore type awareness in PHP?
Ignoring types can cause unexpected bugs, like adding text to numbers or calling functions with wrong data, which can crash your program or give wrong results.
Click to reveal answer
intermediate
How does PHP 7+ help with type awareness?
PHP 7 and later let you declare types for function inputs and outputs, so PHP checks if you use the right types and throws an error if something is wrong.Click to reveal answer
beginner
Give an example of a type declaration in PHP.
Example: function add(int $a, int $b): int { return $a + $b; } This means both inputs and the output must be integers.Click to reveal answer
What does type awareness help prevent in PHP?
✗ Incorrect
Type awareness helps prevent bugs caused by using wrong data types in your code.
Which PHP version introduced scalar type declarations to improve type awareness?
✗ Incorrect
PHP 7 introduced scalar type declarations for better type checking.
What happens if you pass a string to a PHP function expecting an int without type awareness?
✗ Incorrect
Passing wrong types can cause bugs or errors if types are not checked.
Which of these is a benefit of using type declarations in PHP?
✗ Incorrect
Type declarations make code easier to read and more reliable.
What does this PHP function signature mean? function greet(string $name): string
✗ Incorrect
The function expects a string input and returns a string output.
Explain why being aware of data types is important when writing PHP code.
Think about what happens if you mix numbers and text by mistake.
You got /4 concepts.
Describe how PHP 7+ helps programmers with type awareness.
Focus on new features that check types automatically.
You got /4 concepts.