Single vs. Double Quotation Marks

In PHP it’s important to understand how single quotation marks differ from double quotation marks. With the echo() and print() statements you can use either, as in the examples in this chapter. But there is a key difference between the two and why you might use them. So far I’ve specified when you should use which, but now it’s time to define the pattern more explicitly.

In PHP, values enclosed within single quotation marks will be treated literally, whereas those within double quotation marks will be interpreted. In other words, placing variables and special characters (Table 1.2) within double quotes will result in their represented values printed, not their literal values. For example, assume that you have ...

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.