echo "<input type=\"text\" size=3 name=\"{$item[\"name\"]}\"/>";
but following works fine
echo "<input type=\"text\" size=3 name=\"{$item['name']}\"/>";
As per my understanding \” really escape the “
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t need to escape the quotes inside the
{}. That’s supposed to be quoted because it means the string index"name"for the PHP array$name. Without quotes (or escaped quotes),nameis treated as a constant (which I’m assuming it isn’t), and then you’ve got an extra pair of quotes which don’t belong.OTOH, this would also be correct:
(no quotes around
nameand no{}either)see http://www.php.net/manual/en/language.types.string.php#language.types.string.parsing
re:comment
Any non-keyword without quotes or the $ sign is regarded as a constant (as you can define with the define function), thus
"name"(with quotes) is a string, andnamewithout quotes is a constant.when written like this, however:
PHP will first look for a constant with the name
name, then if it doesn’t exist, it will use the string"name". However, it will (depending on your settings?) also issue a warning.