Recall & Review
beginner
What is an escape sequence in PHP strings?
An escape sequence is a way to include special characters in a string that would otherwise be hard to type or have special meaning, like new lines or quotes. It starts with a backslash (\).
Click to reveal answer
beginner
How do you write a newline character inside a PHP string?
Use the escape sequence \n inside double-quoted strings to add a new line.
Click to reveal answer
beginner
What escape sequence do you use to include a double quote inside a double-quoted PHP string?
Use \" to include a double quote inside a double-quoted string.
Click to reveal answer
intermediate
What happens if you use single quotes in PHP strings regarding escape sequences?
In single-quoted strings, only \\' and \\ are recognized as escape sequences. Others like \n are treated as normal characters.
Click to reveal answer
beginner
List three common escape sequences in PHP strings and their meanings.
\n = new line, \t = tab, \" = double quote inside double-quoted string.
Click to reveal answer
Which escape sequence adds a tab space in a PHP double-quoted string?
✗ Incorrect
The escape sequence \t adds a tab space inside double-quoted strings.
How do you write a backslash character inside a PHP string?
✗ Incorrect
Use \\ to represent a single backslash character in a string.
In PHP, which escape sequences work inside single-quoted strings?
✗ Incorrect
Only \\ and \' are recognized as escape sequences inside single-quoted strings.
What will this PHP code output? echo "Hello\nWorld";
✗ Incorrect
The \n creates a new line, so Hello and World appear on separate lines.
Which escape sequence inserts a carriage return in PHP strings?
✗ Incorrect
The escape sequence \r inserts a carriage return character.
Explain how escape sequences work in PHP strings and give examples.
Think about how to include special characters inside strings.
You got /3 concepts.
Describe the difference between escape sequences in single-quoted and double-quoted PHP strings.
Consider which escape sequences are processed in each string type.
You got /3 concepts.