Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPrakhar Patwa
11,260 Pointsvalue="<?php echo $product["name"] ?>" or value="<?php echo $product['name'] ?>" which is true " " or ' ' ?
my main doubt with the " "(double) quotes and ' '(single) quotes
3 Answers
Diren Yardimli
6,494 Pointsin general the only difference is var names inside " are processed. So ["key_$id"] or ['key_'.$id]
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsHi Prakhar Patwa .
As Guan Wu said the main difference with single and double quotes is that if you have a variable name in a double quotes then the variable will be evaluated and parsed - and if you use a single quote then the literal string will be used.
Ted Sumner
Courses Plus Student 17,967 PointsBoth Guan and Nejc are correct. I am only writing to elaborate.
<?php
$name = 'Ted';
echo "My name is $name.";
// returns: My name is Ted.
echo 'My name is $name.';
// returns: My name is $name.
In the context of your question, you must use single quotes around name because you have the entire block enclosed by double quotes. If you use double quotes, it would be interpreted as this:
value="(open quote)<?php echo $product["(close quote)name"(open quote)] ?>"(close quote)