header
 
     
 
pixel
pixel pixel

Using double quotes with variables

When you're outputing variables amongst HTML, if there's a chance there might be an apostrophe ' in your variable, use double quotes in your HTML. For example,
<?php
echo "<img src=\"$filename\">";
?>
Note the escape character \ allowing me to use the double quote. This is particularly important when pulling data from a form or database where you're not certain what might be there.

Unhelpful Helpful Rating 4.1 (score out of 5, no. of ratings: 14)
Comments
Comment by John on 2004-12-03
Another option is: "; ?>

Post a Comment
Name
Email
(optional)
Comment
RatingUnhelpful Helpful
Security Image* (this is just to prevent spam submissions)
Security Image