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 trial

PHP PHP Functions Introducing Functions PHP Function Default Arguments

cynnimon
cynnimon
4,001 Points

Single quotes vs. double quotes in echo and arguments?

I think I missed something, but I noticed that sometimes he uses single quotes for echo, and sometimes he uses double quotes.

Does it matter which quotes you use for echo? Does it also matter when making string variables? i.e. 'Hampton' vs. "Hampton"?

1 Answer

Hi.

Well just on short notice: you need a double quote if you want to evaluate a variable in your string ->

$test = 'Billy the Kid'; //you can use single or double quote

echo "Hello, my name is $test."; //to output the value of variable test into the string-> the string would read: Hello, my name is Billy the Kid.
// you need double quotes for the variable to be evaluated -> // the string would read: Hello, my name is $test.

Here's a link to get more details StackOverflow .

Hope this helped.

cynnimon
cynnimon
4,001 Points

Thanks! It really helps a lot.