I just ran across this little gem in some code I’m looking at. It works, but… I’m not sure I’d ever recommend actually doing it. I’ll show the code first, explain how it works, and then how I’d rewrite it. The following code was in a component, but I can demonstrate it with a simple CFM as well.
<cffunction name="test" output="true">
<cfset test()> <cfdump var=”#variables#”> </code>
Looks a bit odd, right? If you run this, you will actually see IRAN as one of the Variables. The output=”true” on test() evaluates the CFML inside the method. It would be the same as if I had done:
So that works, but, again, it’s a bit odd. I’d rewrite the method like so:
<cffunction name="test" output="false">
It has the exact same effect, but, is a bit more direct. You can toggle output back on again and it won’t change a thing.