Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a string with single quotes.
PHP
$greeting = [1]Hello World[1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes when single quotes are required.
Using backticks which are for shell execution in PHP.
✗ Incorrect
Single quotes are used to create a string literal without variable interpolation in PHP.
2fill in blank
mediumComplete the code to create a string with double quotes.
PHP
$name = [1]John[1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes when double quotes are needed for variable parsing.
Using backticks which are not for strings.
✗ Incorrect
Double quotes allow variable interpolation and special characters in PHP strings.
3fill in blank
hardFix the error in the code to correctly print the variable inside the string.
PHP
echo [1]Hello, $user![1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which print the variable name literally.
Using backticks which execute shell commands.
✗ Incorrect
Double quotes are needed to parse the variable $user inside the string.
4fill in blank
hardFill both blanks to create a string that includes a variable without parsing it.
PHP
$text = [1]The variable is $var[2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using double quotes which parse the variable.
Using mismatched quotes causing syntax errors.
✗ Incorrect
Single quotes prevent variable parsing, so $var is printed literally.
5fill in blank
hardFill all three blanks to create a string with double quotes and escape the inner double quote.
PHP
$quote = [1]He said, [2]Hello![3] to me.[1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not escaping inner double quotes causing syntax errors.
Using single quotes outside which don't allow escaping double quotes inside.
✗ Incorrect
Double quotes start and end the string; inner double quotes are escaped with \".