On Thu, 2003-10-23 at 20:43, Shawn McKenzie wrote: > I came across this post and was hoping to get a gurus opinion on the > validity. TIA > > -Shawn > > I remember reading somewhere re: PHP coding that it is a better coding > practice to use single quotes as much as possible vs. using double quotes in > scripts. When using double quotes, you are forcing PHP to look for variables > within them, even though there may not be any, thus slowing execution > time... > > For example it is better to code: > Code: > echo '<td bgcolor="'.$bgcolor2.'"> </td></tr>'; > > vs. > Code: > echo "<td bgcolor=\"$bgcolor2\"> </td></tr>";
Better is a very subjective question; however, style 1 will run faster since it won't look for variable interpolation. Personally I always use style 1 unless I specifically need variable interpolation or one of the special characters such as a newline. Also when doing HTML the double quotes fit nicely in the the single quote paradigm. On the other hand when I do SQL queries, I often allow interpolation just because it is more readable and because I usually use single quotes to wrap strings in my queries. HTH, Rob. -- .------------------------------------------------------------. | InterJinn Application Framework - http://www.interjinn.com | :------------------------------------------------------------: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `------------------------------------------------------------' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php