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 trialOscar Camacho
Full Stack JavaScript Techdegree Student 5,428 PointsSingle or doble quotation marks
When you write the code <?php echo "Hello World!"; ?> or <?php echo 'Hello World!'; ?> Why Alena Holligan used single quotation marks? or Can you use doble quotation marks? any difference.
1 Answer
Jennifer Nordell
Treehouse TeacherHi Oscar! In this case, yes, you could use either single or double quotes. Either work for this example. The biggest difference is when you have a string containing a variable name in it. Let me show you an example and feel free to run this in a workspace!
<?php
$hello = "Hello World!";
echo "$hello";
echo '$hello';
?>
If/when you run this code the first echo will actually echo out "Hello World!". It expands the variable to retrieve the value inside it and display the value. The single quotes don't do that. They simply echo out the variable name. So the second echo will echo out $hello
.
She could have used either here and achieved the same results. But she had to choose one, and the single quotes is what she chose for this example. Hope this helps!
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherBest answer assigned 2017-07-06 as no other answers are present and answer has been upvoted multiple times.