msgbartop
News, views, tips and tricks on Oracle and other fun stuff
msgbarbottom

To pound or not to pound in ColdFusion

Most Cold Fusion developers overuse the # character. Here are a couple of rules that will help you decide when to “pound” your variables:

  1. #’s are never needed around variable names used in Cold Fusion tag attributes, unless they occur within an attribute string.
  2. #’s are always needed around variables that occur outside of (or in between pairs of) Cold Fusion tags. In other words, variables that occur within a block of text (e.g. SQL code between <CFQUERY> and </CFQUERY>, text in a <CFMAIL> body) must be surrounded by #’s. Similarly, variables with a string (text within double quotes) must be surrounded by #’s too.

And those are the only places to use them.

Related articles:

Filed in ColdFusion on 22 Jun 05 | Tags:


Reader's Comments

  1. |

    Tell me about it! I’ve lost count of the number of times I’ve had to demonstrate the correct use of pound signs in CF.

    This is a good article on the subject by Ben Forta: http://www.defusion.com/articles/index.cfm?ArticleID=26

  2. |

    Thanks for the link Martin. I already have it in my bookmarks. I thought that posting the two rules that Ben had written about would clear up any confusion surrounding the use of pound signs in ColdFusion.