Matt Liotta and Barney Boisvert raised an interesting issue today on cfcdev. We all know, or should know, that cfc methods (and tag based udfs) take an OUTPUT attribute. This supposedly does two things: If set to true, it allows any and all output to be generated by the UDF. If set to false, it acts as if a cfsilent tag surrounded the function. In general, you should almost always use output="false".

However, something odd happens if you leave off the output attribute. It is supposed to default to true, but that is not the case. Consider the following code:

<cfset x = 1>
<cffunction name="test">
hi ray #x#
</cffunction>

<cffunction name="test2" output="true">
hi ray #x#
</cffunction>

<cfset test()>
<cfset test2()>

When test() is run, the string inside the function is output, but #x# is NOT evaluated. It acts just like normal text in a CFML page. When test2() is run, the value of x is evaluated. It acts as if the text were surrounded by cfoutput tags. This could lead to confusion as you may actually want to show #foo# or output an internal anchor link.