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

Trevor Wood
Trevor Wood
17,828 Points

A quick question about PHP

In a text of code like this, the " marks and the ' confuse me a little. To be certain let me see if I got this right.

The first ' is paired with the last ' while the two in the middle are paired together? Or is it opposite? If not, how can the browser distinguish the difference? Because they're inside the " marks does it allow the browser to comprehend?

 echo '<a href="shirt.php?id=' . $product_id . '">';

Any help on this is much appreciated.

1 Answer

I believe the first two will pair together, turning this block of code into a string

'<a href="shirt.php?id='

Then you concatenate the variable, and to that variable you concatenate the next part of your code between single '

'">'

So it's not like html where the tags are nested. The first is closed with the second, the third is closed by the fourth. The " inbetween is treated like a part of the string I suppose, and not considered an opening mark by php.

Trevor Wood
Trevor Wood
17,828 Points

ah, okay I see. I guess that would explain the need for the periods for $product_id.

Thanks Jean +1