Single Quote vs. Double Quote
I recently ran into this little bit of info when working on some code to replace line breaks in a string with some HTML code....
When quoting attributes PHP (Perl as well) treats values wrapped by single quotes as there face value, it will not replaced variables or treat special characters how you would expect. When using double quotes variables are replaced and special character sets are treated normaly.
Here is an example:
<? $FeaturesFixed = "this is the features code"; $FeaturesFixed = ereg_replace ("\n", "<li>", $Features); echo(" <li>$FeaturesFixed"); ?>
<li>this <li>is <li>the <li>features <li>code
now with single quotes
<? $FeaturesFixed = ereg_replace ('\n', '<li>', $Features); echo(" <li>$FeaturesFixed"); ?>
<li>this is the features code
Post new comment