Managing Magic Quotes

Built into PHP is a handy feature referred to as Magic Quotes. Magic Quotes—when enabled—will automatically escape single and double quotation marks in the values of variables. This can help prevent problems when working with databases or HTML. But, if I enter into a form some text that includes an apostrophe (Figure 2.5), the resulting page looks strange when the text is reprinted (Figure 2.6).

Figure 2.5. Quotation marks entered into form values can be disruptive in your Web applications (see Figure 2.6).

Figure 2.6. The apostrophe entered in the form was escaped automatically by PHP, generating unseemly results.

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.