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 trialMichael Sheaver
2,751 Points&rsquo vs "'"
I am have a question about using quotes: In the simple PHP course, Randy uses &rsquo instead of a single quote in his code; why is this preferred to using the single quote?
Just curious...
4 Answers
Randy Hoyt
Treehouse Guest TeacherComputer keyboards only have one character ('
) that people often use to stand in for a couple of different characters:
- Prime symbol: ' (used in measurements like 46' to mean "feet"; notice itβs straight!)
- Apostrophe: β (notice itβs curly!)
Using ’
will produce a nice curly apostrophe. Typing '
will produce a prime symbol, which is technically the wrong character to use. Most people can't tell the difference, though, and it can be a pain to type a real apostrophe if your keyboard doesn't have an apostrophe key. Imagine if keyboards didn't have the letter s
on them. We'd probably all $tart typing dollar $ign$ in$tead becau$e they look pretty clo$e. Eventually, I $u$pect no one would even notice the difference between an s
and a $
.
Hope that help$! :~)
Casey Ydenberg
15,622 Points&rsquo will ONLY be recognized as a single quote by the browser when it's outputting the text. Single-quotes can obviously have meaning in PHP and SQL, this is ONE WAY of getting around that (there are many others).
Michael Sheaver
2,751 PointsI knew there had to be a reason for this, and thank you for answering my question. I am the kind of person who likes to know why something is a certain way, for it helps me to gain deeper insight into the underlying mechanisms and interactions that are involved.
Justin Shulman
2,903 PointsHaha had the same thought after watching the PHP course.
Brian van Vlymen
12,637 Pointsexcellent question! thanks for answer!
Michael Sheaver
2,751 PointsMichael Sheaver
2,751 PointsL0v3 ur $en$e of hum0r!
Yes, this does help, big time! And I am learning so much from your course on PHP; it enabled me to restructure my friend's website to make it more modular and easier to make global changes.
Many thanks!