Careful use of # signs
The
## (pound) sign is very important in Coldfusion.
- <cfoutput>#variablename#</cfoutput>
is OK.
However using ## inside cfset and cfif tags is not good coding.
The following would be considered
bad coding:
- <cfset var1=#variablename#>
-
<cfif #variablename# eq "">
The ## sign are not necessary inside <cfif> and <cfset> tags because it takes more time to execute.
A
good coding standard would be to avoid using pound signs around variables inside cfset and cfif tags:
- <cfset var1=variablename>
-
<cfif variablename eq ""></cfif>
A tidbit of information but valuable nonetheless.
cfinclude and custom tags
All of us are familiar with cfinclude and custom tags, both tags are used to include a file. What is the difference between them?
The main difference between cfinclude and custom tag is that the include tag works in a copy-paste manner. The scope of variables used in the calling page is available in the included page. But custom tags are individual ColdFusion pages, variables and other data are not automatically shared between a custom tag and the calling page, so we have to pass it as arguments.