Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
&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?
Randy HoytTreehouse Guest Teacher
Computer 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!)
’ 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 Ydenberg15,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).
excellent question! thanks for answer!