Recall & Review
beginner
What is the difference between single quotes and double quotes in PHP strings?
Single quotes treat the content literally, while double quotes allow variable interpolation and special escape sequences.
Click to reveal answer
beginner
How does PHP handle variables inside single-quoted strings?
Variables inside single-quoted strings are not parsed; they appear as plain text.
Click to reveal answer
intermediate
Which escape sequences work inside double-quoted strings in PHP?
Escape sequences like \n (newline), \t (tab), \\ (backslash), and \" (double quote) work inside double-quoted strings.
Click to reveal answer
beginner
Show an example of variable interpolation in a double-quoted string in PHP.
Example: $name = 'Alice'; echo "Hello, $name!"; // Outputs: Hello, Alice!
Click to reveal answer
intermediate
Why might you choose single quotes over double quotes in PHP?
Single quotes are faster to process because PHP does not parse variables or most escape sequences inside them.
Click to reveal answer
What will this PHP code output? <br> $name = 'Bob'; <br> echo 'Hello, $name!';
✗ Incorrect
Single quotes do not parse variables, so $name is printed literally.
Which of these escape sequences works inside single-quoted strings in PHP?
✗ Incorrect
Only \' and \\ are recognized inside single-quoted strings.
What will this PHP code output? <br> echo "Line1\nLine2";
✗ Incorrect
In double-quoted strings, \n is interpreted as a newline character.
Which string type allows variable interpolation in PHP?
✗ Incorrect
Only double-quoted strings parse variables inside.
Why might single quotes be preferred over double quotes in PHP?
✗ Incorrect
Single quotes are faster because PHP does not parse variables or most escape sequences inside.
Explain the main differences between single-quoted and double-quoted strings in PHP.
Think about how PHP treats variables and special characters inside each type.
You got /3 concepts.
Give an example showing how variable interpolation works in double-quoted strings but not in single-quoted strings.
Use a variable inside both string types and show the output.
You got /2 concepts.