Basic PHP Programming Question:
Download Questions PDF

What Are the Special Characters You Need to Escape in Double-Quoted Stings?


Answer #1
There are two special characters you need to escape in a double-quote string: the double quote (") and the back slash (). Here is a PHP script example of double-quoted strings:

echo "Hello world!";
echo "Tom said: "Who's there?"";
echo " represents an operator.";

This script will print:

Hello world!Tom said: "Who's there?" represents an operator.

Answer #2
print "Tom Said:\"Who's there?\"";

We need to escape \"(double quotes) by prefixing it with \ (backslash) like the above code

Download PHP Interview Questions And Answers PDF

Previous QuestionNext Question
Can You Specify the "new line" Character in Single-Quoted Strings?How Many Escape Sequences Are Recognized in Double-Quoted Strings in PHP?