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 Build a Simple PHP Application Creating the Menu and Footer Including the Footer and Adding Additional Pages

&rsquo and footer

Hi. I realize that & rsquo ;s is just an apostrophe but why do we use it instead of the normal apostrophe? Is there any a critical purpose for it? Also, Is there a special reason why we included the last </div> from index.php into the cut/pasted code that is now footer.php?

Thanks

2 Answers

Kris Phelps
Kris Phelps
7,609 Points

My guess is that it might be habitual. Apostrophe's, aka single quotes can cause problems in PHP. For example:

<php

echo 'Mike's shirts';

?>

The above code would break, because PHP would think the apostrophe in "Mike's" was ending the echo statement.

There are a couple of ways to fix this:

Using Double quotes, instead of single quotes

echo "Mike's shirts";

"Escaping" the single quote with a backslash:

echo 'Mike\'s shirts';

or using something called HTML Entities:

echo 'Mike&rsquo;s shirts';

Now, because the part of the code he is working on is not enclosed within PHP tags, he doesn't really need to use the entity, which is why I believe he more does it out of habit.

No matter what happens, his code will always work, even if the H1 is enclosed in PHP tags at some point in the future. I hope this helps.

Same question for me. Both seem to work and render ' in the html. Anyone could give any details ?

Thanks