tags:

views:

459

answers:

8

The is a very simple echo statement but I can't solve it?

echo '"What is your name?'";
+22  A: 

Mismatch of single quotes, use this:

echo '"What is your name?"';

Your first enclosing character was single quote but ending one was double quote causing the problem

Sarfraz
+5  A: 

Your single quote (') is misplaced at the end.

Your corrected syntax is this

echo '"What is your name?"';
Starx
+5  A: 

Your quotes are nested incorrectly.

Alex
+1  A: 

quotes are the problem

Starx
+7  A: 

Incorrect:

echo '"What is your name?'";
                          ^ Unexpected character

Correct:

echo '"What is your name?';

Correct:

echo "What is your name?";

Correct:

echo 'What is your name?';

Correct:

echo '"What is your name?"';

Correct:

echo "'What is your name?'";
Dolph
@Sarfraz - how do you figure that? How do you know he doesn't want the single quotes in the string?
nickf
@nickf: I did not say he doesn't want single quotes, I meant he needs his string inside the double quotes something that can be seen from his code, only that he placed ending single quotes wrongly, basically he seems to echo it like this `"What is your name?"`, see double quotes included in the *output*. Something that can be figured out from his code `'"What is your name?"';`
Sarfraz
@sarfraz: `only that he placed ending single quotes wrongly` .. or the starting single quotes were placed wrongly...
nickf
+1  A: 

This is where your interpreter is choking:

echo '"What is your name?'";

expecting ; not "

Babiker
+1  A: 

echo "\"What is your name?\"";

peeto
+1  A: 

echo "What is your name?";

This is Simply the best. No confusion No problem..:)

Neeraj