ColdFusion Tutorial
When to use # or not
There have been a endless debates about when to use a # around ColdFusion variables. Here?s my opinion about that:
Try to avoid the # and if the code doesn?t work properly without it, us the #.
Example:
<cfset doesn?t require # signs.
<cfset var1 = "Hey">
<cfset var2 = myvar>
Unless the variable is in a string:
<cfset var1 = "You have purchased #product# from our store.">
Try this instead:
<cfset var1 = "You have purchased " & product & " from our store.">
Notice: CFOUTPUT usually requires a #.
<cfoutput>#var1#</cfoutput>
ColdFusion Tutorial test
When to use # or not
No test is available or implemented for this ColdFusion Tutorial.
User Comments: 1
How to find "&" in the string stored in a variable
Variable="This is my Question & I would appreciate any help?"
AnotherVariable = "#Variable#"
Question is how can I replace "&" in the above string with any otehr thing (say AND) while passing value of Variable to Another Variable.
