Starx
Starx

Reputation: 78941

PHP Echo syntax error with single quote or double quotes?

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

echo '"What is your name?'";

Upvotes: 10

Views: 3433

Answers (6)

Chris Petersn
Chris Petersn

Reputation: 82

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

Upvotes: 2

Neeraj
Neeraj

Reputation: 483

echo "What is your name?";

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

Upvotes: 0

Sarfraz
Sarfraz

Reputation: 382606

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

Upvotes: 24

Babiker
Babiker

Reputation: 18798

This is where your interpreter is choking:

echo '"What is your name?'";

expecting ; not "

Upvotes: 1

Dolph
Dolph

Reputation: 50650

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?'";

Upvotes: 9

Alex
Alex

Reputation: 3652

Your quotes are nested incorrectly.

Upvotes: 6

Related Questions